<!doctype html>



  


<html class="theme-next muse use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|consolas:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="ionic,cordova,AngularJS," />








  <link rel="shortcut icon" type="image/x-icon" href="http://ofy7k3v4s.bkt.clouddn.com/mylogo.png?v=5.0.2" />






<meta name="description" content="ionic &amp;#x9879;&amp;#x76EE;&amp;#x5B89;&amp;#x88C5;&amp;#x9879;&amp;#x76EE;&amp;#x4F9D;&amp;#x8D56;
&amp;#x5DF2;&amp;#x5728;&amp;#x73AF;&amp;#x5883;&amp;#x914D;&amp;#x7F6E;&amp;#x91CC;&amp;#x9762;&amp;#x8BBE;&amp;#x7F6E;&amp;#x597D;

&amp;#x6253;&amp;#x5F00;&amp;#x547D;&amp;#x4EE4;&amp;#x7A97">
<meta property="og:type" content="article">
<meta property="og:title" content="ionic+cordova+AngularJS混合app开发笔记">
<meta property="og:url" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/index.html">
<meta property="og:site_name" content="HongqinMa' Blog">
<meta property="og:description" content="ionic &amp;#x9879;&amp;#x76EE;&amp;#x5B89;&amp;#x88C5;&amp;#x9879;&amp;#x76EE;&amp;#x4F9D;&amp;#x8D56;
&amp;#x5DF2;&amp;#x5728;&amp;#x73AF;&amp;#x5883;&amp;#x914D;&amp;#x7F6E;&amp;#x91CC;&amp;#x9762;&amp;#x8BBE;&amp;#x7F6E;&amp;#x597D;

&amp;#x6253;&amp;#x5F00;&amp;#x547D;&amp;#x4EE4;&amp;#x7A97">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic20.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/swiper.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic21.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic22.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic23.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic24.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic25.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic26.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic27.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic28.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic29.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic30.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic31.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic32.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic33.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/promise01.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/promise02.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic34.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic35.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic36.png">
<meta property="og:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic37.png">
<meta property="og:updated_time" content="2016-12-23T04:00:25.225Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="ionic+cordova+AngularJS混合app开发笔记">
<meta name="twitter:description" content="ionic &amp;#x9879;&amp;#x76EE;&amp;#x5B89;&amp;#x88C5;&amp;#x9879;&amp;#x76EE;&amp;#x4F9D;&amp;#x8D56;
&amp;#x5DF2;&amp;#x5728;&amp;#x73AF;&amp;#x5883;&amp;#x914D;&amp;#x7F6E;&amp;#x91CC;&amp;#x9762;&amp;#x8BBE;&amp;#x7F6E;&amp;#x597D;

&amp;#x6253;&amp;#x5F00;&amp;#x547D;&amp;#x4EE4;&amp;#x7A97">
<meta name="twitter:image" content="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/ionic20.png">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6347850919329138000',
      author: 'Hiraku'
    }
  };
</script>




  <link rel="canonical" href="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/"/>


  <title> ionic+cordova+AngularJS混合app开发笔记 | HongqinMa' Blog </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="en">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?10010323";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  
    <div class="site-meta-headline">
      <a>
        <img class="custom-logo-image" src="http://ofy7k3v4s.bkt.clouddn.com/photo.jpg"
             alt="HongqinMa' Blog"/>
      </a>
    </div>
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">HongqinMa' Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Spell at all costs， to rush you in the future。</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                ionic+cordova+AngularJS混合app开发笔记
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-12-14T20:41:00+08:00" content="2016-12-14">
              2016-12-14
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Hybrid-APP-开发系列/" itemprop="url" rel="index">
                    <span itemprop="name">Hybrid APP 开发系列</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          
              &nbsp; | &nbsp;
              <span class="page-pv"><i class="fa fa-file-o"></i>
              <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
              </span>
          

          
            <span id="busuanzi_container_page_pv">  <span id="busuanzi_value_page_pv"></span> Views</span>
          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="ionic-&#x9879;&#x76EE;"><a href="#ionic-&#x9879;&#x76EE;" class="headerlink" title="ionic &#x9879;&#x76EE;"></a>ionic &#x9879;&#x76EE;</h2><p>&#x5B89;&#x88C5;&#x9879;&#x76EE;&#x4F9D;&#x8D56;</p>
<p>&#x5DF2;&#x5728;&#x73AF;&#x5883;&#x914D;&#x7F6E;&#x91CC;&#x9762;&#x8BBE;&#x7F6E;&#x597D;</p>
<blockquote>
<p>&#x6253;&#x5F00;&#x547D;&#x4EE4;&#x7A97;&#x53E3;,&#x5728;&#x641C;&#x7D22;&#x4E2D;&#x8F93;&#x5165;cmd<br>&#x8F93;&#x5165;npm install cordova ionic -g</p>
</blockquote>
<p>&#x5FEB;&#x901F;&#x521B;&#x5EFA;&#x9879;&#x76EE;</p>
<blockquote>
<p>&#x5148;&#x627E;&#x5230;&#x4E00;&#x4E2A;&#x653E;&#x9879;&#x76EE;&#x7684;&#x4F4D;&#x7F6E;<br>&#x5728;&#x76EE;&#x5F55;&#x4E2D;&#x6309;&#x4F4F; shift &#x952E;&#x53F3;&#x51FB;,&#x5728;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5939;&#x6253;&#x5F00;&#x547D;&#x4EE4;&#x7A97;&#x53E3;<br>ionic  start  myApp (&#x9ED8;&#x8BA4;&#x662F;tab&#x6837;&#x5F0F;)</p>
</blockquote>
<h3 id="&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x8BF4;&#x660E;"><a href="#&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x8BF4;&#x660E;" class="headerlink" title="&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x8BF4;&#x660E;"></a>&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x8BF4;&#x660E;</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">|-- hooks</div><div class="line">|-- platform &#x624B;&#x673A;&#x5E73;&#x53F0;</div><div class="line">|-- plugins cordova &#x63D2;&#x4EF6;&#x5E93;</div><div class="line">|-- resources &#x56FE;&#x7247;&#x8D44;&#x6E90;</div><div class="line">|-- scss</div><div class="line">|-- www &#x9879;&#x76EE;&#x8D44;&#x6E90;</div><div class="line">|-- .bowerrc bower &#x914D;&#x7F6E;&#x6587;&#x4EF6;</div><div class="line">...</div></pre></td></tr></table></figure>
<h3 id="&#x6253;&#x5305;app"><a href="#&#x6253;&#x5305;app" class="headerlink" title="&#x6253;&#x5305;app"></a>&#x6253;&#x5305;app</h3><blockquote>
<p>&#x5148;&#x627E;&#x5230;&#x9879;&#x76EE;&#x7684;&#x6839;&#x76EE;&#x5F55;<br>&#x5728;&#x76EE;&#x5F55;&#x4E2D;&#x6309;&#x4F4F;shift&#x952E;&#x53F3;&#x51FB;,&#x5728;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5939;&#x6253;&#x5F00;&#x547D;&#x4EE4;&#x7A97;&#x53E3;<br>Ionic  platform  add  android<br>Ionic  build  android</p>
</blockquote>
<h2 id="&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x642D;&#x5EFA;"><a href="#&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x642D;&#x5EFA;" class="headerlink" title="&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x642D;&#x5EFA;"></a>&#x9879;&#x76EE;&#x7ED3;&#x6784;&#x642D;&#x5EFA;</h2><h3 id="&#x8981;&#x4ECE;&#x65B0;&#x6574;&#x7406;&#x7ED3;&#x6784;"><a href="#&#x8981;&#x4ECE;&#x65B0;&#x6574;&#x7406;&#x7ED3;&#x6784;" class="headerlink" title="&#x8981;&#x4ECE;&#x65B0;&#x6574;&#x7406;&#x7ED3;&#x6784;"></a>&#x8981;&#x4ECE;&#x65B0;&#x6574;&#x7406;&#x7ED3;&#x6784;</h3><p>&#x65B9;&#x4FBF;&#x8FD0;&#x7EF4;&#xFF0C;&#x7ED3;&#x6784;&#x6E05;&#x6670;&#xFF0C;&#x65B9;&#x4FBF;&#x67E5;&#x627E;<br>&#x65B9;&#x4FBF;&#x56E2;&#x961F;&#x5F00;&#x53D1;</p>
<h3 id="&#x62BD;&#x53D6;&#x6B65;&#x9AA4;"><a href="#&#x62BD;&#x53D6;&#x6B65;&#x9AA4;" class="headerlink" title="&#x62BD;&#x53D6;&#x6B65;&#x9AA4;"></a>&#x62BD;&#x53D6;&#x6B65;&#x9AA4;</h3><p>&#x63A7;&#x5236;&#x9879;&#x76EE;&#x542F;&#x52A8;&#x7684; app.js</p>
<p>&#x63A7;&#x5236;&#x8DEF;&#x7531;&#x8DF3;&#x8F6C;&#x7684; route.js</p>
<p>&#x63A7;&#x5236;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684; global.js</p>
<p>&#x63A7;&#x5236;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x517C;&#x5BB9;&#x6027;&#x7684; config.js</p>
<h4 id="&#x529F;&#x80FD;&#x6A21;&#x5757;&#x5212;&#x5206;"><a href="#&#x529F;&#x80FD;&#x6A21;&#x5757;&#x5212;&#x5206;" class="headerlink" title="&#x529F;&#x80FD;&#x6A21;&#x5757;&#x5212;&#x5206;"></a>&#x529F;&#x80FD;&#x6A21;&#x5757;&#x5212;&#x5206;</h4><p>Controller&#xFF1A;&#x4E1A;&#x52A1;&#x903B;&#x8F91;</p>
<p>Factory:&#x6570;&#x636E;&#x8BF7;&#x6C42;&#x8BBF;&#x95EE;&#xFF0C;&#x548C;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;&#x3002;</p>
<p>Html&#x9875;&#x9762;&#xFF1A;&#x529F;&#x80FD;&#x754C;&#x9762;</p>
<p>Route:&#x5B50;&#x529F;&#x80FD;&#x8DEF;&#x7531;js&#xFF0C;&#x63A7;&#x5236;&#x6211;&#x4EEC;&#x7684;&#x9875;&#x9762;&#x8DF3;&#x8F6C;&#x3002;</p>
<h4 id="&#x5916;&#x9762;&#x56DB;&#x4E2A;js&#x5B9E;&#x73B0;&#x6B65;&#x9AA4;"><a href="#&#x5916;&#x9762;&#x56DB;&#x4E2A;js&#x5B9E;&#x73B0;&#x6B65;&#x9AA4;" class="headerlink" title="&#x5916;&#x9762;&#x56DB;&#x4E2A;js&#x5B9E;&#x73B0;&#x6B65;&#x9AA4;"></a>&#x5916;&#x9762;&#x56DB;&#x4E2A;js&#x5B9E;&#x73B0;&#x6B65;&#x9AA4;</h4><p>&#x521B;&#x5EFA;&#x56DB;&#x4E2A;&#x63A7;&#x5236;&#x5168;&#x5C40;&#x529F;&#x80FD;&#x7684;js&#x6587;&#x4EF6;</p>
<p>&#x628A;&#x6BCF;&#x4E2A;js&#x6587;&#x4EF6;&#x53D8;&#x6210;&#x6A21;&#x5757;</p>
<blockquote>
<p>app&#xFF1A;run<br>config: config<br>global: constant<br>route: config</p>
</blockquote>
<p>&#x628A;js&#x6587;&#x4EF6;&#x5728;html&#x4E2D;&#x5F15;&#x5165;</p>
<p>&#x5728;app.js &#x6587;&#x4EF6;&#x4E2D;&#x6CE8;&#x5165;&#x6211;&#x4EEC;&#x5176;&#x4ED6;&#x4E09;&#x4E2A;&#x6A21;&#x5757;&#x7684;&#x4E1C;&#x897F;&#xFF08;&#x52A0;&#x5165;&#x529F;&#x80FD;&#xFF09;</p>
<h4 id="app-js"><a href="#app-js" class="headerlink" title="app.js"></a>app.js</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// Ionic Starter App</span></div><div class="line">angular.module(<span class="string">&apos;starter&apos;</span>, [<span class="string">&apos;ionic&apos;</span>,<span class="string">&apos;config&apos;</span>,<span class="string">&apos;global&apos;</span>,<span class="string">&apos;route&apos;</span>,<span class="string">&apos;ionicLazyLoad&apos;</span>,<span class="string">&apos;indexdb&apos;</span>,<span class="string">&apos;commonJs&apos;</span>,<span class="string">&apos;ngCordova&apos;</span>])</div><div class="line">.run(<span class="function"><span class="keyword">function</span>(<span class="params">$ionicPlatform,$location,$ionicHistory,$cordovaToast,$rootScope</span>) </span>{</div><div class="line">  $ionicPlatform.ready(<span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</div><div class="line">    <span class="keyword">if</span> (<span class="built_in">window</span>.cordova &amp;&amp; <span class="built_in">window</span>.cordova.plugins &amp;&amp; <span class="built_in">window</span>.cordova.plugins.Keyboard) {</div><div class="line">      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(<span class="literal">true</span>);</div><div class="line">      cordova.plugins.Keyboard.disableScroll(<span class="literal">true</span>);</div><div class="line">    }</div><div class="line">    <span class="keyword">if</span> (<span class="built_in">window</span>.StatusBar) {</div><div class="line">      <span class="comment">// org.apache.cordova.statusbar required</span></div><div class="line">      StatusBar.styleDefault();</div><div class="line">    }</div><div class="line">    <span class="comment">// &#x7ED9;android&#x7684;&#x7269;&#x7406;&#x8FD4;&#x56DE;&#x6309;&#x94AE;&#x6DFB;&#x52A0;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;</span></div><div class="line">    <span class="comment">// &#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x6CE8;&#x518C;&#x7684;&#x4E8B;&#x4EF6;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x6CE8;&#x518C;&#x4E8B;&#x4EF6;&#x7684;&#x4F18;&#x5148;&#x7EA7;</span></div><div class="line">    $ionicPlatform.registerBackButtonAction(<span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span>{</div><div class="line">      <span class="keyword">if</span>($rootScope.backButtonPressedOnceToExit){</div><div class="line">        ionic.Platform.exitApp();</div><div class="line">      }</div><div class="line">      <span class="keyword">else</span> {</div><div class="line">        <span class="keyword">if</span>($location.path()==<span class="string">&quot;/tab/home&quot;</span>||$location.path()==<span class="string">&quot;/tab/category&quot;</span>||$location.path()==<span class="string">&quot;/tab/account&quot;</span>||$location.path()==<span class="string">&quot;/tab/cart&quot;</span>){</div><div class="line">          $rootScope.backButtonPressedOnceToExit=<span class="literal">true</span>;</div><div class="line">          $cordovaToast.showShortBottom(<span class="string">&apos;&#x518D;&#x70B9;&#x4E00;&#x6B21;&#x9000;&#x51FA;&#xFF01;&apos;</span>);</div><div class="line">          setTimeout(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">            $rootScope.backButtonPressedOnceToExit=<span class="literal">false</span>;</div><div class="line">          },<span class="number">2000</span>)</div><div class="line">        }</div><div class="line">        <span class="keyword">else</span> {</div><div class="line">          $ionicHistory.goBack();</div><div class="line">        }</div><div class="line">      }</div><div class="line">      e.preventDefault();</div><div class="line">      <span class="keyword">return</span> <span class="literal">false</span></div><div class="line">    },<span class="number">110</span>);</div><div class="line">  });</div><div class="line">});</div></pre></td></tr></table></figure>
<h4 id="route-js"><a href="#route-js" class="headerlink" title="route.js"></a>route.js</h4><p>&#x901A;&#x8FC7; angular.module.config &#x65B9;&#x6CD5;&#x5B9A;&#x4E49;&#x8DEF;&#x7531;</p>
<p>&#x5F15;&#x5165; $stateProvider(), $urlRouterProvider</p>
<p>&#x5C31;&#x662F;&#x6839;&#x636E;&#x6D4F;&#x89C8;&#x5668;url&#x5730;&#x5740;&#x540E;&#x9762; # &#x90E8;&#x5206;&#x540E;&#x9762;&#x4F60;&#x7684;&#x53D8;&#x5316;&#x5339;&#x914D;&#x4E0D;&#x540C;&#x7684;&#x8DEF;&#x7531;&#xFF0C;&#x5339;&#x914D;&#x5230;&#x5408;&#x9002;&#x7684;&#x8DEF;&#x7531;&#x4E4B;&#x540E;&#xFF0C;&#x5C31;&#x4F1A;&#x628A; templateUrl &#x4E2D;&#x5199;&#x5F97;&#x9875;&#x9762;&#x6A21;&#x677F;&#x6E32;&#x67D3;&#x5230;&#x6211;&#x4EEC;&#x9875;&#x9762;&#x4E2D;&#x7684;<code>&lt;ion-vav-view&gt;</code>,&#x5982;&#x679C;&#x9875;&#x9762;&#x4E2D;&#x6709;&#x5F88;&#x591A;&#x7684;<code>&lt;ion-nav-view&gt;</code>&#x7EC4;&#x4EF6;&#xFF0C;&#x4ED6;&#x5C31;&#x4F1A;&#x6839;&#x636E;&#x7EC4;&#x4EF6;&#x4E2D;&#x7684;name&#x5C5E;&#x6027;&#x7684;&#x503C;&#x8FDB;&#x884C;&#x9009;&#x62E9;&#x6E32;&#x67D3;&#x3002;Controller&#x5C5E;&#x6027;&#x4E2D;&#x7684;&#x63A7;&#x5236;&#x5668;&#x4F1A;&#x88AB;&#x81EA;&#x52A8;&#x6E32;&#x67D3;&#x5230;&#x6A21;&#x677F;&#x9875;&#x9762;&#x4E2D;&#xFF0C;&#x53D8;&#x4E3A;<code>ng-controller=&quot;&#x63A7;&#x5236;&#x5668;&#x540D;&#x79F0;&quot;</code>&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line">angular.module(<span class="string">&apos;route&apos;</span>, [</div><div class="line">  <span class="string">&apos;guidePage.route&apos;</span>,</div><div class="line">  <span class="string">&apos;tab.route&apos;</span>,</div><div class="line">  <span class="string">&apos;home.route&apos;</span>,</div><div class="line">  <span class="string">&apos;category.route&apos;</span>,</div><div class="line">  <span class="string">&apos;goodsList.route&apos;</span>,</div><div class="line">  <span class="string">&apos;details.route&apos;</span>,</div><div class="line">  <span class="string">&apos;cart.route&apos;</span>,</div><div class="line">  <span class="string">&apos;account.route&apos;</span></div><div class="line">])</div><div class="line">  .config(<span class="function"><span class="keyword">function</span>(<span class="params">$stateProvider, $urlRouterProvider</span>) </span>{</div><div class="line">    <span class="comment">// &#x7B2C;&#x4E00;&#x6B21;&#x767B;&#x9646;</span></div><div class="line">    <span class="keyword">if</span>(localStorage[<span class="string">&quot;isFirst&quot;</span>])</div><div class="line">    {</div><div class="line">      $urlRouterProvider.otherwise(<span class="string">&apos;/tab/home&apos;</span>);</div><div class="line">    }</div><div class="line">    <span class="keyword">else</span> {</div><div class="line">      $urlRouterProvider.otherwise(<span class="string">&apos;/guidePage&apos;</span>);</div><div class="line">    }</div><div class="line">  });</div></pre></td></tr></table></figure>
<h4 id="Global-Js"><a href="#Global-Js" class="headerlink" title="Global.Js"></a>Global.Js</h4><p>&#x901A;&#x8FC7; angular.module.constant &#x5B9A;&#x4E49;&#x6210;&#x6A21;&#x5757;&#xFF0C;&#x4E0D;&#x7ECF;&#x5E38;&#x6539;&#x53D8;&#x7684;&#x4E1C;&#x897F;&#x653E;&#x5728;&#x8FD9;&#x91CC;&#x9762;&#x3002;</p>
<p>&#x5982;&#x679C;&#x8981;&#x4F7F;&#x7528;&#xFF0C;&#x5728;&#x5176;&#x4ED6;&#x6A21;&#x5757;&#x4E2D;&#x6CE8;&#x5165;&#x670D;&#x52A1;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#xFF0C;&#x6BD4;&#x5982; GlobalVariable&#xFF0C;&#x5728;&#x5176;&#x4ED6;&#x6A21;&#x5757;&#x4E2D;&#x5C31;&#x53EF;&#x4EE5;&#x628A;&#x91CC;&#x9762;&#x7684;&#x5C5E;&#x6027;&#x90FD;&#x70B9;&#x51FA;&#x6765;&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// &#x5168;&#x5C40;&#x53D8;&#x91CF;&#x6A21;&#x5757;</span></div><div class="line">angular.module(<span class="string">&apos;global&apos;</span>, [])</div><div class="line">  .constant(<span class="string">&quot;GlobalVariable&quot;</span>,{</div><div class="line">    <span class="string">&apos;HTTP&apos;</span>: <span class="string">&apos;https&apos;</span>,</div><div class="line">    <span class="string">&apos;SERVER_PATH&apos;</span>:<span class="string">&apos;http://192.168.1.1&apos;</span>,<span class="comment">// &#x670D;&#x52A1;&#x5668;&#x5730;&#x5740;</span></div><div class="line">    <span class="string">&apos;VERSION&apos;</span>:<span class="string">&quot;0.0.1&quot;</span>,</div><div class="line">    <span class="string">&apos;PORT&apos;</span>:<span class="string">&apos;8080&apos;</span></div><div class="line">  });</div></pre></td></tr></table></figure>
<h4 id="Config-js"><a href="#Config-js" class="headerlink" title="Config.js"></a>Config.js</h4><p>&#x901A;&#x8FC7; angular.module.config &#x5B9A;&#x4E49;&#x6210;&#x6A21;&#x5757;</p>
<p>&#x6CE8;&#x5165; $ionicConfigProvider &#x670D;&#x52A1;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// &#x914D;&#x7F6E;&#x6A21;&#x5757;&#xFF0C;&#x63A7;&#x5236;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x7684;&#x517C;&#x5BB9;&#x6027;</span></div><div class="line">angular.module(<span class="string">&apos;config&apos;</span>, [])</div><div class="line">  .config(<span class="function"><span class="keyword">function</span>(<span class="params">$ionicConfigProvider</span>)</span>{</div><div class="line">    $ionicConfigProvider.platform.android.tabs.position(<span class="string">&quot;bottom&quot;</span>);</div><div class="line">    $ionicConfigProvider.platform.ios.tabs.position(<span class="string">&quot;bottom&quot;</span>);</div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.ios.tabs.style(&apos;standard&apos;);</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.ios.tabs.position(&apos;bottom&apos;);</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.android.tabs.style(&apos;standard&apos;);</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.android.tabs.position(&apos;bottom&apos;);</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.ios.navBar.alignTitle(&apos;center&apos;);</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.android.navBar.alignTitle(&apos;center&apos;);</span></div><div class="line">    <span class="comment">//</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.ios.backButton.previousTitleText(&apos;&apos;).icon(&apos;ion-ios-arrow-thin-left&apos;);</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.android.backButton.previousTitleText(&apos;&apos;).icon(&apos;ion-android-arrow-back&apos;);</span></div><div class="line">    <span class="comment">//</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.ios.views.transition(&apos;ios&apos;);</span></div><div class="line">    <span class="comment">//$ionicConfigProvider.platform.android.views.transition(&apos;android&apos;);</span></div><div class="line">  })</div></pre></td></tr></table></figure>
<p><code>ng-app  --(starter)--&gt;  app.js --&gt; &#x5F15;&#x8FDB;&#x5176;&#x5B83;&#x6A21;&#x5757;</code></p>
<h3 id="&#x529F;&#x80FD;&#x6A21;&#x5757;-js-&#x7684;&#x6574;&#x7406;&#x6B65;&#x9AA4;"><a href="#&#x529F;&#x80FD;&#x6A21;&#x5757;-js-&#x7684;&#x6574;&#x7406;&#x6B65;&#x9AA4;" class="headerlink" title="&#x529F;&#x80FD;&#x6A21;&#x5757; js &#x7684;&#x6574;&#x7406;&#x6B65;&#x9AA4;"></a>&#x529F;&#x80FD;&#x6A21;&#x5757; js &#x7684;&#x6574;&#x7406;&#x6B65;&#x9AA4;</h3><p>1&#x3001;  &#x521B;&#x5EFA;&#x56DB;&#x4E2A;&#x6587;&#x4EF6;</p>
<blockquote>
<p>Controller&#x6587;&#x4EF6;&#xFF1A;&#x63A7;&#x5236;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x7684;<br>Route&#x6587;&#x4EF6;&#xFF1A;&#x529F;&#x80FD;&#x6A21;&#x5757;&#x8DEF;&#x7531;<br>Service&#x6587;&#x4EF6;&#xFF1A;&#x6570;&#x636E;&#x8BF7;&#x6C42;&#x8BBF;&#x95EE;&#x7684;<br>Html&#x9875;&#x9762;</p>
</blockquote>
<p>2&#x3001;&#x628A;&#x6BCF;&#x4E2A;js&#x6587;&#x4EF6;&#x53D8;&#x6210;&#x6A21;&#x5757;</p>
<blockquote>
<p>Controller: angular.module.controller<br>route: angular.moduleconfig<br>service: angular.modulefactory<br>route: angular.moduleconfig</p>
</blockquote>
<p>3&#x3001;&#x628A; js &#x6587;&#x4EF6;&#x5728; html &#x4E2D;&#x5F15;&#x5165;</p>
<p>4&#x3001;&#x5728;&#x6A21;&#x5757; js &#x6587;&#x4EF6;&#x4E2D;&#x6CE8;&#x5165;&#x9700;&#x8981;&#x7684;&#x670D;&#x52A1;&#x548C;&#x6A21;&#x5757;</p>
<p>&#x603B;&#x7ED3;&#xFF1A;&#x9875;&#x9762;&#x542F;&#x52A8;&#x6D41;&#x7A0B;&#xFF1A;</p>
<p>&#x547D;&#x540D;&#x89C4;&#x8303;</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">index </div><div class="line">&lt;body na-app=&apos;starter&apos;&gt; &lt;/body&gt;</div><div class="line">ionic.bundle.js &#x6587;&#x4EF6;&#x4E2D;&#x6709; angular.js</div><div class="line">starter &#x5165;&#x53E3;&#x6A21;&#x5757;</div><div class="line">&apos;ionic&apos;,&apos;config&apos;,&apos;global&apos;,&apos;route&apos;</div><div class="line">&apos;ionicLazyLoad&apos;,&apos;indexdb&apos;,&apos;commonJs&apos;,&apos;ngCordova&apos;</div><div class="line">|-- ionic &#x662F; bundle.js &#x4E2D;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x662F; ionic &#x6846;&#x67B6;&#x81EA;&#x5B9A;&#x4E49;&#x7684;</div><div class="line">|-- congfig &#x517C;&#x5BB9;&#x6027;&#x914D;&#x7F6E; .config(function($ionicConfigProvider){})</div><div class="line">|-- global constant &#x7684;&#x4E1C;&#x897F;&#x6267;&#x884C; .constant(&quot;GlobalVariable&quot;,{})</div><div class="line">|-- route &#x529F;&#x80FD;&#x6A21;&#x5757;&#x7684;&#x5165;&#x53E3;&#x6587;&#x4EF6; .config(function($stateProvider, $urlRouterProvider){})</div><div class="line">  |-- guidePage.route   .config(function($stateProvider, $urlRouterProvider){})</div><div class="line">    |-- guidePage.controller  .controller(&apos;GuidePageCtrl&apos;,function ($scope, $state){})</div><div class="line">      |-- guidePage.service  .factory(&apos;GuidePageFty&apos;, function(){})</div><div class="line">|-- route &#x6709;&#x4E00;&#x4E2A;&#xFF1A;$urlRouterProvider.otherwise(&apos;/guidePage&apos;);</div><div class="line">&lt;ion-nav-view&gt;&lt;/ion-nav-view&gt; &#x6A21;&#x677F;&#x9875;&#x9762;&#x6E32;&#x67D3;&#x5230;&#x4E86;&#x5B83;&#x6240;&#x5728;&#x7684;&#x5730;&#x65B9;</div></pre></td></tr></table></figure>
<h3 id="&#x6269;&#x5C55;&#x94FE;&#x63A5;"><a href="#&#x6269;&#x5C55;&#x94FE;&#x63A5;" class="headerlink" title="&#x6269;&#x5C55;&#x94FE;&#x63A5;"></a>&#x6269;&#x5C55;&#x94FE;&#x63A5;</h3><p><a href="http://ngionic.com/2014/12/ionic-javascript-api-ionicconfigprovider/" target="_blank" rel="external">http://ngionic.com/2014/12/ionic-javascript-api-ionicconfigprovider/</a><br><a href="http://ngionic.com/2014/12/ionic-javascript-api-ion-view-%E8%A7%86%E5%9B%BE%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%8F%8A%E4%BA%8B%E4%BB%B6%E9%9B%86%E5%90%88/" target="_blank" rel="external">http://ngionic.com/2014/12/ionic-javascript-api-ion-view-%E8%A7%86%E5%9B%BE%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%8F%8A%E4%BA%8B%E4%BB%B6%E9%9B%86%E5%90%88/</a></p>
<p>ionic css<br>ionic js&#xFF1A; angular &#x6307;&#x4EE4;<br>ionic &#x56FE;&#x6807;&#x5E93;</p>
<h2 id="&#x8DEF;&#x7531;"><a href="#&#x8DEF;&#x7531;" class="headerlink" title="&#x8DEF;&#x7531;"></a>&#x8DEF;&#x7531;</h2><h3 id="Ui-router&#x7684;&#x4ECB;&#x7ECD;"><a href="#Ui-router&#x7684;&#x4ECB;&#x7ECD;" class="headerlink" title="Ui-router&#x7684;&#x4ECB;&#x7ECD;"></a>Ui-router&#x7684;&#x4ECB;&#x7ECD;</h3><p>Github&#x5730;&#x5740;&#xFF1A;<a href="https://github.com/angular-ui/ui-router" target="_blank" rel="external">https://github.com/angular-ui/ui-router</a></p>
<p>ui-router &#x4ED6;&#x7B97;&#x662F;angular&#x4E2D;&#x8FDB;&#x884C;&#x8DEF;&#x7531;&#x8DF3;&#x8F6C;&#x7684;&#x4E00;&#x4E2A;&#x7B2C;&#x4E09;&#x65B9;&#x63D2;&#x4EF6;&#xFF0C;&#x672C;&#x8D28;&#x662F;&#x5BF9; ng-route &#x8FDB;&#x884C;&#x4E86;&#x4E00;&#x4E9B;&#x5C01;&#x88C5;&#x3002;</p>
<blockquote>
<p>&#x901A;&#x8FC7; npm install angular-ui-router &#x4E0B;&#x8F7D;<br>&#x5728; index.html &#x542F;&#x52A8;&#x9875;&#x9762;&#x4E2D;&#x5F15;&#x5165; js &#x6587;&#x4EF6;&#xFF0C;&#x5F15;&#x5165;&#x987A;&#x5E8F;&#x8981;&#x6CE8;&#x610F;&#xFF0C;&#x56E0;&#x4E3A;&#x9700;&#x8981; angular &#x4E2D;&#x7684; ng-route &#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x6240;&#x4EE5;&#x8981;&#x5728;&#x5F15;&#x5165; angular.js&#x6587;&#x4EF6;&#x4E4B;&#x540E;&#x5F15;&#x5165;&#x3002;<br>&#x9700;&#x8981;&#x5F15;&#x5165; ui-router &#x6A21;&#x5757;<br>&#x5728; html &#x4E2D;&#x7684;&#x67D0;&#x4E2A;&#x6807;&#x7B7E;&#x52A0;&#x4E0A; ui-view &#x6807;&#x7B7E;&#xFF0C;&#x4F5C;&#x7528;&#x5C31;&#x662F;&#x5728;&#x9875;&#x9762;&#x4E2D;&#x6316;&#x4E86;&#x4E00;&#x4E2A;&#x5751;&#xFF0C;&#x4E4B;&#x540E;&#x7684;&#x6A21;&#x677F;&#x9875;&#x9762;&#x5C31;&#x5F80;&#x8FD9;&#x91CC;&#x9762;&#x586B;&#x3002;<br>&#x5728; js &#x6587;&#x4EF6;&#x4E2D;&#x7F16;&#x5199;&#x6211;&#x4EEC;&#x7684;&#x8DEF;&#x7531;&#x3002;<br>&#x6839;&#x636E;&#x6D4F;&#x89C8;&#x5668;&#x5730;&#x5740;&#x680F;&#x7684;&#x53D8;&#x5316;&#xFF0C;&#x5339;&#x914D;&#x4E0D;&#x540C;&#x7684;&#x8DEF;&#x7531;&#xFF0C;&#x7136;&#x540E;&#x8FDB;&#x884C;&#x6A21;&#x677F;&#x9875;&#x9762;&#x7684;&#x6E32;&#x67D3;&#x548C;&#x63A7;&#x5236;&#x5668;&#x7684;&#x52A0;&#x8F7D;&#x3002;</p>
</blockquote>
<h3 id="&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x7684;&#x5B9E;&#x73B0;"><a href="#&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x7684;&#x5B9E;&#x73B0;" class="headerlink" title="&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x7684;&#x5B9E;&#x73B0;"></a>&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x7684;&#x5B9E;&#x73B0;</h3><p>&#x4E3A;&#x4E86;&#x5B9E;&#x73B0;&#x5728;&#x4E00;&#x4E2A;&#x9875;&#x9762;&#x4E2D;&#x53EF;&#x4EE5;&#x51FA;&#x73B0;&#x591A;&#x4E2A;&#x5751;&#xFF08;&#x6A21;&#x677F;&#x9875;&#x9762;&#x66FF;&#x6362;&#x4F4D;&#x7F6E;&#xFF09;&#xFF0C;&#x624D;&#x5B9E;&#x73B0;&#x4E86;&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x7684;&#x6982;&#x5FF5;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic20.png" alt="&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x7684;&#x5B9E;&#x73B0;"></p>
<p>&#x6CE8;&#x610F;&#x70B9;&#xFF1A;</p>
<blockquote>
<p>&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x662F;&#x4E0D;&#x4F1A;&#x88AB;&#x5355;&#x72EC;&#x5339;&#x914D;&#x6E32;&#x67D3;&#x7684;&#xFF0C;&#x53EA;&#x6709;&#x914D;&#x5408;&#x5B50;&#x8DEF;&#x7531;&#x7684;&#x5B9E;&#x73B0;&#x624D;&#x80FD;&#x6E32;&#x67D3;&#x865A;&#x62DF;&#x8DEF;&#x7531;&#x4E2D;&#x7684;&#x6A21;&#x677F;<br>&#x5B50;&#x8DEF;&#x7531;&#x4E2D;&#x7684;&#x8DEF;&#x7531;&#x540D;&#x79F0;&#x4E2D;&#x7684;&#x70B9;&#x662F;&#x6709;&#x5B9E;&#x9645;&#x610F;&#x4E49;&#x7684;&#xFF0C;&#x662F;&#x4E3A;&#x4E86;&#x914D;&#x5408;&#x865A;&#x62DF;&#x8DEF;&#x7531;&#xFF0C;&#x5B9E;&#x73B0;&#x7236;&#x5B50;&#x8DEF;&#x7531;&#x7684;&#x5C42;&#x7EA7;&#x5173;&#x7CFB;&#x3002;</p>
</blockquote>
<h3 id="ionic&#x4E2D;&#x8DEF;&#x7531;&#x5B9E;&#x73B0;"><a href="#ionic&#x4E2D;&#x8DEF;&#x7531;&#x5B9E;&#x73B0;" class="headerlink" title="ionic&#x4E2D;&#x8DEF;&#x7531;&#x5B9E;&#x73B0;"></a>ionic&#x4E2D;&#x8DEF;&#x7531;&#x5B9E;&#x73B0;</h3><blockquote>
<p>&#x5728;index&#x9875;&#x9762;&#x4E2D;&#x52A0;&#x5165;<code>&lt;ion-nav-view&gt;&lt;/ion-nav-view&gt;</code>&#x6807;&#x7B7E;&#xFF0C;&#x5728; ionic &#x4E2D; ui-router &#x7684; ui-view &#x5DF2;&#x7ECF;&#x88AB;<code>&lt;ion-nav-view&gt;</code>&#x7EC4;&#x4EF6;&#x5C01;&#x88C5;&#x4E86;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x4F1A;&#x51FA;&#x73B0;&#x5728;&#x9875;&#x9762;&#x4E2D;&#x3002;<br>&#x8981;&#x5199;&#x8DEF;&#x7531;&#x6A21;&#x5757;&#x7684;&#x914D;&#x7F6E;&#x4FE1;&#x606F;&#xFF0C;&#x901A;&#x8FC7;angular.module.config&#x914D;&#x7F6E;&#x8DEF;&#x7531;&#x4FE1;&#x606F;&#xFF08;&#x8BBE;&#x7F6E;&#x8DEF;&#x7531;&#x540D;&#x79F0;&#xFF0C;url&#x5730;&#x5740;&#xFF0C;&#x6A21;&#x677F;&#x9875;&#x9762;&#xFF0C;controller&#xFF09;<br>&#x5728;index.html&#x9875;&#x9762;&#x628A;&#x8DEF;&#x7531;js&#x5F15;&#x8FDB;&#x6765;&#xFF0C;&#x5728;app.js&#x4E2D;&#x6CE8;&#x5165;&#x8DEF;&#x7531;&#x6A21;&#x5757;&#x7684;&#x529F;&#x80FD;<br>&#x628A;&#x9875;&#x9762;&#x7684;&#x529F;&#x80FD;&#x5305;&#x88F9;&#x5728;ion-view&#x6216;&#x8005;&#x662F;ion-tab&#x6807;&#x7B7E;&#x4E2D;<br>&#x6839;&#x636E;&#x6D4F;&#x89C8;&#x5668;&#x4E2D;url&#x5730;&#x5740;&#x7684;&#x53D8;&#x5316;&#xFF0C;&#x5339;&#x914D;&#x4E0D;&#x540C;&#x7684;&#x8DEF;&#x7531;<br>&#x6E32;&#x67D3;&#x6211;&#x4EEC;&#x7684;&#x6A21;&#x677F;&#x9875;&#x9762;&#x5230;&#x76F8;&#x5E94;&#x7684;<code>&lt;ion-nav-view&gt;&lt;/ion-nav-view&gt;</code>&#x7EC4;&#x4EF6;&#x4E2D;</p>
</blockquote>
<h3 id="tab-router-js"><a href="#tab-router-js" class="headerlink" title="tab_router.js"></a>tab_router.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">angular.module(<span class="string">&apos;tab.route&apos;</span>, [<span class="string">&apos;tab.controller&apos;</span>])</div><div class="line">  .config(<span class="function"><span class="keyword">function</span>(<span class="params">$stateProvider, $urlRouterProvider</span>) </span>{</div><div class="line">    $stateProvider</div><div class="line">      .state(<span class="string">&apos;tab&apos;</span>, {</div><div class="line">        <span class="attr">url</span>: <span class="string">&apos;/tab&apos;</span>,</div><div class="line">        <span class="comment">// &#x62BD;&#x8C61;&#x8DEF;&#x7531;</span></div><div class="line">        abstract: <span class="literal">true</span>,</div><div class="line">        <span class="attr">templateUrl</span>: <span class="string">&apos;areas/tab/tab.html&apos;</span>,</div><div class="line">        <span class="attr">controller</span>: <span class="string">&apos;TabCtrl&apos;</span></div><div class="line">      })</div><div class="line">  });</div></pre></td></tr></table></figure>
<h3 id="home-route-js"><a href="#home-route-js" class="headerlink" title="home_route.js"></a>home_route.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">angular.module(<span class="string">&apos;home.route&apos;</span>, [<span class="string">&apos;home.controller&apos;</span>])</div><div class="line">  .config(<span class="function"><span class="keyword">function</span> (<span class="params">$stateProvider, $urlRouterProvider</span>) </span>{</div><div class="line">      $stateProvider</div><div class="line">      .state(<span class="string">&apos;tab.home&apos;</span>, {</div><div class="line">        <span class="attr">url</span>: <span class="string">&apos;/home&apos;</span>,</div><div class="line">        <span class="attr">views</span>: {</div><div class="line">          <span class="string">&apos;tab-home&apos;</span>: {</div><div class="line">            <span class="attr">templateUrl</span>: <span class="string">&apos;areas/home/home.html&apos;</span>,</div><div class="line">            <span class="attr">controller</span>: <span class="string">&apos;HomeCtrl&apos;</span></div><div class="line">          }</div><div class="line">        }</div><div class="line">      })</div><div class="line">  });</div></pre></td></tr></table></figure>
<p><code>.</code> &#x662F;&#x6709;&#x5B9E;&#x9645;&#x610F;&#x4E49;&#x7684;&#xFF1A;&#x8868;&#x660E;&#x662F;&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x7684;&#x5B50;&#x8DEF;&#x7531;&#x3002;</p>
<p>&#x6B64;&#x65F6;&#x7684;&#x8DEF;&#x7531;&#x5C31;&#x662F;&#xFF1A;<code>/tab/home</code></p>
<h3 id="route-js-1"><a href="#route-js-1" class="headerlink" title="route.js"></a>route.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">angular.module(<span class="string">&apos;route&apos;</span>, [</div><div class="line">  <span class="string">&apos;guidePage.route&apos;</span>,</div><div class="line">  <span class="string">&apos;tab.route&apos;</span>,</div><div class="line">  <span class="string">&apos;home.route&apos;</span>,</div><div class="line">  <span class="string">&apos;starter.controllers&apos;</span>,</div><div class="line">  <span class="string">&apos;starter.services&apos;</span></div><div class="line">])</div><div class="line">.config(<span class="function"><span class="keyword">function</span>(<span class="params">$stateProvider, $urlRouterProvider</span>) </span>{</div><div class="line">  $urlRouterProvider.otherwise(<span class="string">&apos;/tab/home&apos;</span>);</div><div class="line">  });</div></pre></td></tr></table></figure>
<h3 id="index-html"><a href="#index-html" class="headerlink" title="index.html"></a>index.html</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!--tab&#x5207;&#x6362;--&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/tab/tab_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/tab/tab_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="comment">&lt;!--&#x9996;&#x9875;--&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/home/home_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/home/home_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/home/home_service.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span> <span class="attr">ng-app</span>=<span class="string">&quot;starter&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">ion-nav-view</span>&gt;</span><span class="tag">&lt;/<span class="name">ion-nav-view</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div></pre></td></tr></table></figure>
<p>&#x8FD9;&#x6837;&#x73B0;&#x5728;&#x9875;&#x9762;&#x5C31;&#x6709;&#x56DB;&#x4E2A;&#x5751;&#x4E86;&#x3002;</p>
<h2 id="&#x5F15;&#x5BFC;&#x9875;&#x7684;&#x5B9E;&#x73B0;"><a href="#&#x5F15;&#x5BFC;&#x9875;&#x7684;&#x5B9E;&#x73B0;" class="headerlink" title="&#x5F15;&#x5BFC;&#x9875;&#x7684;&#x5B9E;&#x73B0;"></a>&#x5F15;&#x5BFC;&#x9875;&#x7684;&#x5B9E;&#x73B0;</h2><h3 id="&#x521B;&#x5EFA;&#x5F15;&#x5BFC;&#x9875;&#x6B65;&#x9AA4;"><a href="#&#x521B;&#x5EFA;&#x5F15;&#x5BFC;&#x9875;&#x6B65;&#x9AA4;" class="headerlink" title="&#x521B;&#x5EFA;&#x5F15;&#x5BFC;&#x9875;&#x6B65;&#x9AA4;"></a>&#x521B;&#x5EFA;&#x5F15;&#x5BFC;&#x9875;&#x6B65;&#x9AA4;</h3><blockquote>
<p>&#x521B;&#x5EFA;&#x56DB;&#x4E2A;&#x529F;&#x80FD;&#x6A21;&#x5757;&#x6587;&#x4EF6;<br>&#x7F16;&#x5199;&#x6A21;&#x5757;&#x529F;&#x80FD;&#xFF0C;&#xFF08;&#x8FD9;&#x91CC;&#x4ECE;&#x4E4B;&#x524D;&#x7684;&#x4EE3;&#x7801;&#x590D;&#x5236; html &#x9875;&#x9762;&#x548C; css &#x6837;&#x5F0F;&#xFF09;<br>&#x5728; index.html &#x9875;&#x9762;&#x4E2D;&#x5F15;&#x5165;&#x4E09;&#x4E2A;&#x6587;&#x4EF6;(controller, route, service)<br>&#x5C06;&#x529F;&#x80FD;&#x8DEF;&#x7531;&#x5728;&#x603B;&#x8DEF;&#x7531;&#x4E2D;&#x6CE8;&#x5165;</p>
</blockquote>
<h3 id="Swiper3&#x7B80;&#x4ECB;"><a href="#Swiper3&#x7B80;&#x4ECB;" class="headerlink" title="Swiper3&#x7B80;&#x4ECB;"></a>Swiper3&#x7B80;&#x4ECB;</h3><p>&#x5B98;&#x7F51;&#xFF1A;<a href="http://www.swiper.com.cn/" target="_blank" rel="external">http://www.swiper.com.cn/</a></p>
<p>Swier3&#x63D2;&#x4EF6;&#x7ED3;&#x6784;&#xFF1A;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/swiper.png" alt="Swiper"></p>
<h3 id="&#x4F7F;&#x7528;swiper&#x6B65;&#x9AA4;"><a href="#&#x4F7F;&#x7528;swiper&#x6B65;&#x9AA4;" class="headerlink" title="&#x4F7F;&#x7528;swiper&#x6B65;&#x9AA4;"></a>&#x4F7F;&#x7528;swiper&#x6B65;&#x9AA4;</h3><blockquote>
<p>&#x5728;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x4F4D;&#x7F6E;&#x6253;&#x5F00;&#x5F00;&#x547D;&#x4EE4;&#x7A97;&#x53E3;&#xFF0C;&#x8F93;&#x5165; npm install bower &#x2013;g<br>&#x5728;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x6253;&#x5F00;&#x547D;&#x4EE4;&#x7A97;&#x53E3;&#xFF0C;&#x8F93;&#x5165; bower install swiper &#x2013;save<br>&#x5728; index.html &#x9875;&#x9762;&#x5F15;&#x5165; swiper.min.css&#xFF0C;swiper.min.js<br>&#x628A;&#x9875;&#x9762;&#x4E2D;&#x7684; html &#x4EE3;&#x7801;&#x52A0;&#x4E0A;&#x5BF9;&#x5E94;&#x7684; class &#x6837;&#x5F0F;<br>&#x5728; controller &#x4E2D;&#x521D;&#x59CB;&#x5316; swiper &#x63D2;&#x4EF6;&#xFF0C;&#x5E76;&#x8BBE;&#x7F6E;&#x76F8;&#x5E94;&#x7684;&#x5C5E;&#x6027;</p>
</blockquote>
<h2 id="&#x9996;&#x9875;&#x7684;&#x5B9E;&#x73B0;"><a href="#&#x9996;&#x9875;&#x7684;&#x5B9E;&#x73B0;" class="headerlink" title="&#x9996;&#x9875;&#x7684;&#x5B9E;&#x73B0;"></a>&#x9996;&#x9875;&#x7684;&#x5B9E;&#x73B0;</h2><h3 id="&#x9879;&#x76EE;&#x5E03;&#x5C40;&#x6539;&#x9020;"><a href="#&#x9879;&#x76EE;&#x5E03;&#x5C40;&#x6539;&#x9020;" class="headerlink" title="&#x9879;&#x76EE;&#x5E03;&#x5C40;&#x6539;&#x9020;"></a>&#x9879;&#x76EE;&#x5E03;&#x5C40;&#x6539;&#x9020;</h3><p>&#x521B;&#x5EFA;&#x56DB;&#x4E2A;&#x9996;&#x9875;&#x9762;&#x529F;&#x80FD;&#x6587;&#x4EF6;,&#x4FEE;&#x6539;&#x91CC;&#x9762;&#x7684;&#x5185;&#x5BB9;</p>
<p>&#x5728; index &#x9875;&#x9762;&#x5F15;&#x5165;&#x56DB;&#x4E2A;&#x6587;&#x4EF6;</p>
<p>&#x5728;&#x603B;&#x8DEF;&#x7531;&#x4E2D;&#x6CE8;&#x5165;&#x5B50;&#x529F;&#x80FD;&#x8DEF;&#x7531;&#xFF0C;controller, service &#x4E5F;&#x90FD;&#x8981;&#x5728;&#x5B50;&#x529F;&#x80FD;&#x8DEF;&#x7531;&#x4E2D;&#x6CE8;&#x5165;</p>
<h3 id="Tab&#x6A21;&#x677F;&#x6539;&#x9020;"><a href="#Tab&#x6A21;&#x677F;&#x6539;&#x9020;" class="headerlink" title="Tab&#x6A21;&#x677F;&#x6539;&#x9020;"></a>Tab&#x6A21;&#x677F;&#x6539;&#x9020;</h3><blockquote>
<p>&#x5BF9; ion-tabs &#x91CC;&#x9762;&#x53D8;&#x4E3A;&#x56DB;&#x4E2A; ion-tab s&#x7EC4;&#x4EF6;<br>&#x5BF9;&#x56DB;&#x4E2A; ion-tab &#x7EC4;&#x4EF6;&#x7684;&#x540D;&#x79F0;&#xFF0C;&#x56FE;&#x6807;&#xFF0C;&#x8DF3;&#x8F6C;&#x5730;&#x5740;&#x8FDB;&#x884C;&#x4E86;&#x4FEE;&#x6539;&#xFF0C;ion-nav-view &#x7EC4;&#x4EF6;&#x7684; name &#x5C5E;&#x6027;&#x6539;&#x6389;<br>&#x628A; tabs &#x7684;&#x62BD;&#x8C61;&#x8DEF;&#x7531;&#x7ED9;&#x62BD;&#x53D6;&#x4E86;&#x51FA;&#x6765;&#xFF0C;&#x53D8;&#x4E3A;&#x4E00;&#x4E2A;&#x529F;&#x80FD;&#x6A21;&#x5757;<br>&#x5728; index &#x9875;&#x9762;&#x4E2D;&#x5F15;&#x5165; tabs &#x7684;&#x76F8;&#x5173;&#x6587;&#x4EF6;<br>&#x5728;&#x603B;&#x8DEF;&#x7531;&#x4E2D;&#x6CE8;&#x5165; tabs.route &#x6A21;&#x5757;</p>
</blockquote>
<h3 id="&#x52A8;&#x6001;&#x751F;&#x6210;swiper"><a href="#&#x52A8;&#x6001;&#x751F;&#x6210;swiper" class="headerlink" title="&#x52A8;&#x6001;&#x751F;&#x6210;swiper"></a>&#x52A8;&#x6001;&#x751F;&#x6210;swiper</h3><blockquote>
<p>&#x5728;controller&#x4E2D;&#x6A21;&#x62DF;&#x8BF7;&#x6C42;&#x540E;&#x53F0;&#x6570;&#x636E;&#xFF0C;&#x628A;&#x8BF7;&#x6C42;&#x56DE;&#x6765;&#x7684;&#x6570;&#x636E;&#x653E;&#x5230;$scope&#x4E0A;<br>&#x5728;html&#x9875;&#x9762;&#x4E2D;&#x901A;&#x8FC7;ng-repeat&#x6307;&#x4EE4;&#x5FAA;&#x73AF;&#x751F;&#x6210;slider&#x6ED1;&#x52A8;&#x9875;<br>&#x521D;&#x59CB;&#x5316;swiper&#x5BF9;&#x8C61;&#xFF0C;&#x6CE8;&#x610F;&#x6700;&#x597D;&#x628A;observeParents&#xFF0C;observer&#x8FD9;&#x4E24;&#x4E2A;&#x5C5E;&#x6027;&#x8BBE;&#x7F6E;&#x4E3A;true.<br>&#x8981;&#x6CE8;&#x610F;&#x521D;&#x59CB;&#x5316;swiper&#x7684;&#x65F6;&#x95F4;&#xFF0C;&#x6700;&#x597D;&#x653E;&#x5728;$ionicView.afterEnter&#x4E2D;</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;utf-8&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">&quot;viewport&quot;</span> <span class="attr">content</span>=<span class="string">&quot;initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span><span class="tag">&lt;/<span class="name">title</span>&gt;</span></div><div class="line"></div><div class="line">    <span class="comment">&lt;!--&#x516C;&#x5171;css--&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;lib/ionic/css/ionic.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;css/common.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line"></div><div class="line">    <span class="comment">&lt;!--&#x529F;&#x80FD;&#x6A21;&#x5757;css--&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;css/guidePage/guidePage.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;css/home/home.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;css/category/category.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;css/goodsList/goodsList.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;css/details/details.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;css/cart/cart.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;css/account/account.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">href</span>=<span class="string">&quot;lib/Swiper/dist/css/swiper.css&quot;</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span>&gt;</span></div><div class="line"></div><div class="line">    <span class="comment">&lt;!-- ionic/angularjs js --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;lib/ionic/js/ionic.bundle.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"></div><div class="line">    <span class="comment">&lt;!-- cordova script (this will be a 404 during development) --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;cordova.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"></div><div class="line">    <span class="comment">&lt;!-- &#x5168;&#x5C40;js&#x6587;&#x4EF6; --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;js/app.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;js/route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;js/global.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;js/config.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/common/indexdb.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/common/common.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"></div><div class="line">    <span class="comment">&lt;!--&#x529F;&#x80FD;&#x6A21;&#x5757;js--&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/guidePage/guidePage_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/guidePage/guidePage_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/guidePage/guidePage_service.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/tab/tab_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/tab/tab_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/home/home_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/home/home_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/home/home_service.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/category/category_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/category/category_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/category/category_service.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/goodsList/goodsList_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/goodsList/goodsList_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/goodsList/goodsList_service.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/details/details_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/details/details_service.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/details/details_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/cart/cart_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/cart/cart_service.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/cart/cart_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/account/account_controller.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/account/account_service.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;areas/account/account_route.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"></div><div class="line">    <span class="comment">&lt;!--&#x7B2C;&#x4E09;&#x65B9;&#x63D2;&#x4EF6;js--&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;lib/Swiper/dist/js/swiper.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;lib/jquery/dist/jquery.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;lib/ionic-image-lazy-load/ionic-image-lazy-load.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;lib/ngCordova/dist/ng-cordova.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">body</span> <span class="attr">ng-app</span>=<span class="string">&quot;starter&quot;</span>&gt;</span></div><div class="line">    <span class="comment">&lt;!--</span></div><div class="line">      The nav bar that will be updated as we navigate between views.</div><div class="line">    --&gt;</div><div class="line">    <span class="comment">&lt;!--&lt;ion-nav-bar class=&quot;bar-stable&quot;&gt;--&gt;</span></div><div class="line">      <span class="comment">&lt;!--&lt;ion-nav-back-button&gt;--&gt;</span></div><div class="line">      <span class="comment">&lt;!--&lt;/ion-nav-back-button&gt;--&gt;</span></div><div class="line">    <span class="comment">&lt;!--&lt;/ion-nav-bar&gt;--&gt;</span></div><div class="line">    <span class="comment">&lt;!--</span></div><div class="line">      The views will be rendered in the &lt;ion-nav-view&gt; directive below</div><div class="line">      Templates are in the /templates folder (but you could also</div><div class="line">      have templates inline in this html file if you&apos;d like).</div><div class="line">    --&gt;</div><div class="line">    <span class="tag">&lt;<span class="name">ion-nav-view</span>&gt;</span><span class="tag">&lt;/<span class="name">ion-nav-view</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<h2 id="ion-view-&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;"><a href="#ion-view-&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;" class="headerlink" title="ion-view &#x7684;&#x751F;&#x547D;&#x5468;&#x671F;"></a>ion-view &#x7684;&#x751F;&#x547D;&#x5468;&#x671F;</h2><p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic21.png" alt="ion-view&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;"><br><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic22.png" alt="ion-view&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;"></p>
<h2 id="ionic&#x4E2D;&#x6E05;&#x7406;&#x7F13;&#x5B58;&#x7684;&#x56DB;&#x79CD;&#x65B9;&#x6CD5;"><a href="#ionic&#x4E2D;&#x6E05;&#x7406;&#x7F13;&#x5B58;&#x7684;&#x56DB;&#x79CD;&#x65B9;&#x6CD5;" class="headerlink" title="ionic&#x4E2D;&#x6E05;&#x7406;&#x7F13;&#x5B58;&#x7684;&#x56DB;&#x79CD;&#x65B9;&#x6CD5;"></a>ionic&#x4E2D;&#x6E05;&#x7406;&#x7F13;&#x5B58;&#x7684;&#x56DB;&#x79CD;&#x65B9;&#x6CD5;</h2><p><a href="http://ionicframework.com/docs/api/directive/ionNavView/" target="_blank" rel="external">http://ionicframework.com/docs/api/directive/ionNavView/</a></p>
<h2 id="&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x7684;&#x5B9E;&#x73B0;"><a href="#&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x7684;&#x5B9E;&#x73B0;" class="headerlink" title="&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x7684;&#x5B9E;&#x73B0;"></a>&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x7684;&#x5B9E;&#x73B0;</h2><p>Imagelazyload:<br><a href="http://www.cnblogs.com/cloudgamer/archive/2010/03/03/ImagesLazyLoad.html" target="_blank" rel="external">http://www.cnblogs.com/cloudgamer/archive/2010/03/03/ImagesLazyLoad.html</a></p>
<p>jquery.lazyload&#x4E0D;&#x80FD;&#x5728;ionic&#x4E2D;&#x4F7F;&#x7528;:<br><a href="http://www.cnblogs.com/yzg1/p/5051554.html" target="_blank" rel="external">http://www.cnblogs.com/yzg1/p/5051554.html</a></p>
<p>angular&#x4E2D;&#x5B9E;&#x73B0;&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;<br><a href="http://segmentfault.com/q/1010000002730440?_ea=192608" target="_blank" rel="external">http://segmentfault.com/q/1010000002730440?_ea=192608</a></p>
<p>me-lazyimg<br><a href="https://github.com/Treri/me-lazyimg/blob/master/me-lazyimg.js" target="_blank" rel="external">https://github.com/Treri/me-lazyimg/blob/master/me-lazyimg.js</a></p>
<p>angular-imglazyload<br><a href="https://www.npmjs.com/package/angular-imglazyload" target="_blank" rel="external">https://www.npmjs.com/package/angular-imglazyload</a></p>
<p>ionic-image-lazy-load&#xFF08;&#x4E13;&#x95E8;&#x7684; ionic &#x56FE;&#x7247;&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x63D2;&#x4EF6;&#xFF09;<br><a href="https://github.com/paveisistemas/ionic-image-lazy-load" target="_blank" rel="external">https://github.com/paveisistemas/ionic-image-lazy-load</a></p>
<h3 id="&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x63D2;&#x4EF6;&#x4F7F;&#x7528;&#x6B65;&#x9AA4;"><a href="#&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x63D2;&#x4EF6;&#x4F7F;&#x7528;&#x6B65;&#x9AA4;" class="headerlink" title="&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x63D2;&#x4EF6;&#x4F7F;&#x7528;&#x6B65;&#x9AA4;"></a>&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x63D2;&#x4EF6;&#x4F7F;&#x7528;&#x6B65;&#x9AA4;</h3><p>&#x7528; bower &#x8FDB;&#x884C;&#x4E0B;&#x8F7D; </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ bower install ion-image-lazy-load --save</div></pre></td></tr></table></figure>
<p>&#x5728; index &#x9875;&#x9762;&#x4E2D;&#x5F15;&#x5165; ion-image-lazy-load.js &#x6587;&#x4EF6;</p>
<p>&#x5728; app.js &#x4E2D;&#x6CE8;&#x5165; ionicLazyLoad &#x670D;&#x52A1;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic23.png" alt="&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x63D2;&#x4EF6;"></p>
<p>&#x5728; ion-content &#x7EC4;&#x4EF6;&#x4E0A;&#x52A0;&#x4E0A; lazy-scroll &#x6307;&#x4EE4;&#xFF0C;&#x6CE8;&#x610F; lazy-scroll &#x6307;&#x4EE4;&#x53EA;&#x80FD;&#x4F5C;&#x7528;&#x4E8E; Ionic-content &#x7EC4;&#x4EF6;&#x4E0A;&#x3002;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic24.png" alt="&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x63D2;&#x4EF6;"></p>
<p>&#x628A;&#x6EDA;&#x52A8;&#x5BB9;&#x5668;&#x4E2D;&#x6240;&#x6709; img &#x6807;&#x7B7E;&#x7684; src &#x5C5E;&#x6027;&#x66FF;&#x6362;&#x4E3A; image-lazy-src</p>
<h2 id="ionic&#x4E2D;&#x7684;&#x9875;&#x9762;&#x8DF3;&#x8F6C;&#x548C;&#x53C2;&#x6570;&#x4F20;&#x9012;"><a href="#ionic&#x4E2D;&#x7684;&#x9875;&#x9762;&#x8DF3;&#x8F6C;&#x548C;&#x53C2;&#x6570;&#x4F20;&#x9012;" class="headerlink" title="ionic&#x4E2D;&#x7684;&#x9875;&#x9762;&#x8DF3;&#x8F6C;&#x548C;&#x53C2;&#x6570;&#x4F20;&#x9012;"></a>ionic&#x4E2D;&#x7684;&#x9875;&#x9762;&#x8DF3;&#x8F6C;&#x548C;&#x53C2;&#x6570;&#x4F20;&#x9012;</h2><h3 id="ionic&#x4E2D;&#x7684;&#x8DEF;&#x7531;&#x8DF3;&#x8F6C;&#x65B9;&#x5F0F;"><a href="#ionic&#x4E2D;&#x7684;&#x8DEF;&#x7531;&#x8DF3;&#x8F6C;&#x65B9;&#x5F0F;" class="headerlink" title="ionic&#x4E2D;&#x7684;&#x8DEF;&#x7531;&#x8DF3;&#x8F6C;&#x65B9;&#x5F0F;"></a>ionic&#x4E2D;&#x7684;&#x8DEF;&#x7531;&#x8DF3;&#x8F6C;&#x65B9;&#x5F0F;</h3><p>&#x901A;&#x8FC7;&#x4EE3;&#x7801;&#x7684;&#x65B9;&#x5F0F;&#x8FDB;&#x884C;&#x8DF3;&#x8F6C;</p>
<p>&#xFF08;1&#xFF09;&#x5728; controller &#x91CC;&#x9762;&#x6CE8;&#x5165; $state &#x670D;&#x52A1;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic25.png" alt="ionic&#x4E2D;&#x7684;&#x8DEF;&#x7531;&#x8DF3;&#x8F6C;&#x65B9;&#x5F0F;"></p>
<p>&#xFF08;2&#xFF09;&#x5728;&#x9875;&#x9762;&#x4E2D;&#x7ED9;&#x5355;&#x51FB;&#x6309;&#x94AE;&#x589E;&#x52A0;&#x5355;&#x51FB;&#x4E8B;&#x4EF6;<br>&#xFF08;3&#xFF09;&#x5728;&#x4E8B;&#x4EF6;&#x65B9;&#x6CD5;&#x91CC;&#x9762;&#x8C03;&#x7528; $state.go(&#x201C;&#x8DEF;&#x7531;&#x540D;&#x79F0;&#x201D;)</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic26.png" alt="ionic&#x4E2D;&#x7684;&#x8DEF;&#x7531;&#x8DF3;&#x8F6C;&#x65B9;&#x5F0F;"></p>
<p>&#x901A;&#x8FC7; href &#x5C5E;&#x6027;&#x8FDB;&#x884C;&#x8DF3;&#x8F6C;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x5199;&#x6211;&#x4EEC;&#x8DF3;&#x8F6C;&#x7684;&#x951A;&#x8BB0;&#xFF0C;url&#x5730;&#x5740;&#x8FDB;&#x884C;&#x8DF3;&#x8F6C;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic27.png" alt="&#x901A;&#x8FC7;href &#x5C5E;&#x6027;&#x8FDB;&#x884C;&#x8DF3;&#x8F6C;"></p>
<p>&#x901A;&#x8FC7;ui-sref&#x5C5E;&#x6027;&#x8FDB;&#x884C;&#x8DF3;&#x8F6C;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic28.png" alt="&#x901A;&#x8FC7;ui-sref&#x5C5E;&#x6027;&#x8FDB;&#x884C;&#x8DF3;&#x8F6C;"></p>
<p>&#x7B2C;&#x4E00;&#x79CD;&#x65B9;&#x5F0F;&#x5728; js &#x4EE3;&#x7801;&#x91CC;&#xFF0C;&#x6BD4;&#x5982;&#x5355;&#x51FB;&#x4E8B;&#x4EF6;&#x4E2D;&#xFF0C;&#x7B2C;&#x4E8C;&#x79CD;&#x5F97;&#x62FC;&#x63A5; #&#xFF0C;&#x7B2C;&#x4E09;&#x79CD;&#x76F4;&#x63A5;&#x5B9A;&#x4E49;&#x8DEF;&#x7531;&#x540D;&#x79F0;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;</p>
<h3 id="ionic&#x4E2D;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;"><a href="#ionic&#x4E2D;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;" class="headerlink" title="ionic&#x4E2D;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;"></a>ionic&#x4E2D;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;</h3><p>&#x5148;&#x4FEE;&#x6539;&#x8DEF;&#x7531;&#xFF0C;&#x5728;&#x8DEF;&#x7531;&#x4E2D;&#x52A0;&#x4E0A;&#x53C2;&#x6570;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic29.png" alt="ionic&#x4E2D;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;"></p>
<p>&#x5C06;&#x53C2;&#x6570;&#x8FDB;&#x884C;&#x4F20;&#x9012;</p>
<p>&#xFF08;1&#xFF09;ui-sref&#xFF1A;ui-sref=&#x201D;goodsList({typeNumber:1})&#x201D;<br>&#xFF08;2&#xFF09;<a href="http://my.oschina.net/u/1416844/blog/470741" target="_blank" rel="external">http://my.oschina.net/u/1416844/blog/470741</a></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#/goodsList/34&quot;</span>&gt;</span>&#x8DF3;&#x8F6C;&#x5230;&#x5546;&#x54C1;&#x8BE6;&#x7EC6;&#x9875;&#x9762;<span class="tag">&lt;/<span class="name">a</span>&gt;</span></div></pre></td></tr></table></figure>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic30.png" alt="&#x5C06;&#x53C2;&#x6570;&#x8FDB;&#x884C;&#x4F20;&#x9012;"></p>
<p>&#xFF08;3&#xFF09;&#x4EE3;&#x7801;&#x8DF3;&#x8F6C;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$state.go(<span class="string">&apos;goodsList&apos;</span>, {<span class="attr">typeNumber</span>:<span class="number">666</span>});</div></pre></td></tr></table></figure>
<p>&#x5728; controller &#x91CC;&#x9762;&#x6CE8;&#x5165; $stateParams &#x670D;&#x52A1;&#xFF0C;&#x662F;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x5BF9;&#x8C61;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic31.png" alt="&#x53C2;&#x6570;&#x4F20;&#x9012;"></p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic32.png" alt="&#x53C2;&#x6570;&#x4F20;&#x9012;"></p>
<p>&#x5176;&#x4ED6;&#xFF1A;&#x7528; LoaclStorage &#x4F20;&#x9012;&#x53C2;&#x6570;&#x3002;</p>
<h2 id="&#x6570;&#x636E;&#x8BF7;&#x6C42;"><a href="#&#x6570;&#x636E;&#x8BF7;&#x6C42;" class="headerlink" title="&#x6570;&#x636E;&#x8BF7;&#x6C42;"></a>&#x6570;&#x636E;&#x8BF7;&#x6C42;</h2><h3 id="Angular&#x4E2D;&#x7684;service-&#x7236;&#x7EA7;&#x6982;&#x5FF5;"><a href="#Angular&#x4E2D;&#x7684;service-&#x7236;&#x7EA7;&#x6982;&#x5FF5;" class="headerlink" title="Angular&#x4E2D;&#x7684;service(&#x7236;&#x7EA7;&#x6982;&#x5FF5;)"></a>Angular&#x4E2D;&#x7684;service(&#x7236;&#x7EA7;&#x6982;&#x5FF5;)</h3><p>&#x5305;&#x542B;Service,Factory,Provider&#x4E09;&#x4E2A;&#x5B50;&#x7EA7;&#x6982;&#x5FF5;&#xFF0C;&#x90FD;&#x662F;&#x8FD4;&#x56DE;service&#xFF08;&#x7236;&#x7EA7;&#x6982;&#x5FF5;&#xFF09;&#x5BF9;&#x8C61;</p>
<p>&#x4E09;&#x79CD;&#x6982;&#x5FF5;&#x5B9A;&#x4E49;&#x6A21;&#x5757;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;</p>
<blockquote>
<p>Factory:&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x533F;&#x540D;&#x5BF9;&#x8C61;&#xFF0C;&#x533F;&#x540D;&#x5BF9;&#x8C61;&#x4E2D;&#x662F;&#x65B9;&#x6CD5;&#x7684;&#x96C6;&#x5408;<br>Service:&#x5728;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x8FD4;&#x56DE;&#x591A;&#x4E2A;&#x670D;&#x52A1;&#xFF0C;&#x9002;&#x5408;&#x7528;service&#x521B;&#x5EFA;&#x6A21;&#x5757;<br>Provider&#xFF1A;&#x662F;service&#x7684;&#x5E95;&#x5C42;&#x5B9E;&#x73B0;&#xFF0C;angular&#x672C;&#x8EAB;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x63D0;&#x4F9B;&#x7684;&#x670D;&#x52A1;</p>
</blockquote>
<h3 id="http&#x670D;&#x52A1;&#x4F7F;&#x7528;"><a href="#http&#x670D;&#x52A1;&#x4F7F;&#x7528;" class="headerlink" title="$http&#x670D;&#x52A1;&#x4F7F;&#x7528;"></a>$http&#x670D;&#x52A1;&#x4F7F;&#x7528;</h3><p>$http&#x4F7F;&#x7528;&#x7B80;&#x4ECB;<br><a href="http://www.2cto.com/kf/201506/405137.html" target="_blank" rel="external">http://www.2cto.com/kf/201506/405137.html</a></p>
<p>&#x5728;Factory&#x4E2D;&#x6CE8;&#x5165;$http&#x670D;&#x52A1;</p>
<p>&#x8BF7;&#x6C42;&#x4F7F;&#x7528;</p>
<p>$http&#x670D;&#x52A1;&#x7684;&#x8DE8;&#x57DF;&#x8BF7;&#x6C42;&#x8BBF;&#x95EE;</p>
<h3 id="q&#x670D;&#x52A1;"><a href="#q&#x670D;&#x52A1;" class="headerlink" title="$q&#x670D;&#x52A1;"></a>$q&#x670D;&#x52A1;</h3><p>$q&#x670D;&#x52A1;&#x7684;&#x4F7F;&#x7528;&#xFF1A;<br><a href="http://blog.csdn.net/renfufei/article/details/19174015" target="_blank" rel="external">http://blog.csdn.net/renfufei/article/details/19174015</a></p>
<blockquote>
<p>$q &#x670D;&#x52A1;&#x4F7F;&#x7528;&#x6B65;&#x9AA4;&#xFF1A;</p>
</blockquote>
<p>&#x9996;&#x5148;&#x8981;&#x5B50;&#x554A;factoruy&#x4E2D;&#x6CE8;&#x5165;$q&#x670D;&#x52A1;</p>
<p>&#x5728;Factory&#x4E2D;&#x4F7F;&#x7528;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic33.png" alt="&#x5728;Factory&#x4E2D;&#x4F7F;&#x7528;"></p>
<p>&#x5728;controller&#x4E2D;&#x4F7F;&#x7528;</p>
<p>&#x4E0A;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x7684;&#x8F93;&#x5165;&#x65F6;&#x4E0B;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x7684;&#x8F93;&#x5165;</p>
<h2 id="Promise-A-&#x89C4;&#x8303;"><a href="#Promise-A-&#x89C4;&#x8303;" class="headerlink" title="Promise/A+&#x89C4;&#x8303;"></a>Promise/A+&#x89C4;&#x8303;</h2><h3 id="Promise-A-&#x89C4;&#x8303;&#x7B80;&#x4ECB;"><a href="#Promise-A-&#x89C4;&#x8303;&#x7B80;&#x4ECB;" class="headerlink" title="Promise/A+&#x89C4;&#x8303;&#x7B80;&#x4ECB;"></a>Promise/A+&#x89C4;&#x8303;&#x7B80;&#x4ECB;</h3><p><a href="http://www.jb51.net/article/50725.htm" target="_blank" rel="external">http://www.jb51.net/article/50725.htm</a></p>
<p>Es6&#x4E2D;&#x7684;promise&#x89C4;&#x8303;<br><a href="http://web.jobbole.com/85297/" target="_blank" rel="external">http://web.jobbole.com/85297/</a></p>
<h3 id="Promise&#x7684;&#x5B9E;&#x73B0;"><a href="#Promise&#x7684;&#x5B9E;&#x73B0;" class="headerlink" title="Promise&#x7684;&#x5B9E;&#x73B0;"></a>Promise&#x7684;&#x5B9E;&#x73B0;</h3><p>&#x56E0;&#x4E3A;&#x4ED6;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x89C4;&#x8303;&#xFF0C;&#x6240;&#x4EE5;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x6846;&#x67B6;&#x6216;&#x8005;&#x5E73;&#x53F0;&#x4E0B;&#x6709;&#x4E0D;&#x540C;&#x7684;&#x5B9E;&#x73B0;</p>
<blockquote>
<p>Angular&#xFF1A;$q&#x670D;&#x52A1;<br>Node&#xFF1A;q&#x6A21;&#x5757;&#xFF0C;co&#xFF0C;then<br>Es6: Promise,  yield<br>Es7&#xFF1A;async  await</p>
</blockquote>
<h3 id="&#x89C4;&#x8303;&#x51FA;&#x73B0;&#x7684;&#x539F;&#x56E0;"><a href="#&#x89C4;&#x8303;&#x51FA;&#x73B0;&#x7684;&#x539F;&#x56E0;" class="headerlink" title="&#x89C4;&#x8303;&#x51FA;&#x73B0;&#x7684;&#x539F;&#x56E0;"></a>&#x89C4;&#x8303;&#x51FA;&#x73B0;&#x7684;&#x539F;&#x56E0;</h3><p>&#x6211;&#x4EEC;&#x4E0D;&#x77E5;&#x9053;&#x5F02;&#x6B65;&#x8BF7;&#x6C42;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x8FD4;&#x56DE;&#x6570;&#x636E;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x5C31;&#x9700;&#x8981;&#x4E9B;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x3002;&#x4F46;&#x662F;&#x5728;&#x67D0;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x77E5;&#x9053;&#x6570;&#x636E;&#x662F;&#x5728;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x8FD4;&#x56DE;&#x7684;&#xFF0C;&#x7136;&#x540E;&#x8FDB;&#x884C;&#x4E00;&#x4E9B;&#x5904;&#x7406;&#x3002;</p>
<p>&#x5F53;&#x6211;&#x4EEC;&#x5728;&#x5F02;&#x6B65;&#x56DE;&#x8C03;&#x91CC;&#x9762;&#x5904;&#x7406;&#x7684;&#x64CD;&#x4F5C;&#x8FD8;&#x662F;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x5F62;&#x6210;&#x4E86;&#x5F02;&#x6B65;&#x56DE;&#x8C03;&#x7684;&#x5D4C;&#x5957; </p>
<p>&#x6B63;&#x662F;&#x4E3A;&#x4E86;&#x675C;&#x7EDD;&#x4EE5;&#x4E0A;&#x4E24;&#x79CD;&#x60C5;&#x51B5;&#x7684;&#x51FA;&#x73B0;&#xFF0C;&#x793E;&#x533A;&#x51FA;&#x73B0;&#x4E86; Promise/a+ &#x89C4;&#x8303;</p>
<p>&#x603B;&#x7ED3;</p>
<blockquote>
<p>Promise/a+&#x51FA;&#x73B0;&#x5C31;&#x662F;&#x4E3A;&#x4E86;&#x89E3;&#x51B3;&#x5F02;&#x6B65;&#x6DF1;&#x5C42;&#x5D4C;&#x5957;<br>Promise/a+&#x672C;&#x8D28;&#x5C31;&#x662F;&#x6539;&#x53D8;&#x4E86;&#x4E00;&#x79CD;&#x4E66;&#x5199;&#x683C;&#x5F0F;</p>
</blockquote>
<h3 id="&#x89C4;&#x8303;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x4EC0;&#x4E48;&#xFF08;&#x91CD;&#x8981;&#xFF09;"><a href="#&#x89C4;&#x8303;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x4EC0;&#x4E48;&#xFF08;&#x91CD;&#x8981;&#xFF09;" class="headerlink" title="&#x89C4;&#x8303;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x4EC0;&#x4E48;&#xFF08;&#x91CD;&#x8981;&#xFF09;"></a>&#x89C4;&#x8303;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x4EC0;&#x4E48;&#xFF08;&#x91CD;&#x8981;&#xFF09;</h3><p>&#x4E0D;&#x7BA1;&#x8FDB;&#x884C;&#x4EC0;&#x4E48;&#x64CD;&#x4F5C;&#x90FD;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A; promise &#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x91CC;&#x9762;&#x4F1A;&#x6709;&#x4E00;&#x4E9B;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#xFF08;&#x8FD9;&#x4E2A;&#x6548;&#x679C;&#x7C7B;&#x4F3C;&#x4E8E; jquery &#x4E2D;&#x7684;&#x94FE;&#x5F0F;&#x7F16;&#x7A0B;&#xFF0C;&#x8FD4;&#x56DE;&#x81EA;&#x5DF1;&#x672C;&#x8EAB;&#xFF09;</p>
<p>&#x8FD9;&#x4E2A;promise&#x6709;&#x4E09;&#x79CD;&#x72B6;&#x6001;</p>
<blockquote>
<p>Unfulfilled&#xFF08;&#x672A;&#x5B8C;&#x6210;&#xFF0C;&#x521D;&#x59CB;&#x72B6;&#x6001;&#xFF09;<br>Fulfilled&#xFF08;&#x5DF2;&#x5B8C;&#x6210;&#xFF09;<br>Failed&#xFF08;&#x5931;&#x8D25;&#x3001;&#x62D2;&#x7EDD;&#xFF09;</p>
</blockquote>
<p>3&#x3001;&#x8FD9;&#x4E2A;promise&#x5BF9;&#x8C61;&#x7684;&#x4F7F;&#x7528;&#x65F6;&#x901A;&#x8FC7;then&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x7684;&#x8C03;&#x7528;</p>
<h3 id="&#x539F;&#x7406;&#x56FE;"><a href="#&#x539F;&#x7406;&#x56FE;" class="headerlink" title="&#x539F;&#x7406;&#x56FE;"></a>&#x539F;&#x7406;&#x56FE;</h3><p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/promise01.png" alt="&#x539F;&#x7406;&#x56FE;"></p>
<h3 id="&#x600E;&#x4E48;&#x5BF9;promise&#x5BF9;&#x8C61;&#x7684;&#x72B6;&#x6001;&#x8FDB;&#x884C;&#x6539;&#x53D8;&#x90A3;"><a href="#&#x600E;&#x4E48;&#x5BF9;promise&#x5BF9;&#x8C61;&#x7684;&#x72B6;&#x6001;&#x8FDB;&#x884C;&#x6539;&#x53D8;&#x90A3;" class="headerlink" title="&#x600E;&#x4E48;&#x5BF9;promise&#x5BF9;&#x8C61;&#x7684;&#x72B6;&#x6001;&#x8FDB;&#x884C;&#x6539;&#x53D8;&#x90A3;"></a>&#x600E;&#x4E48;&#x5BF9;promise&#x5BF9;&#x8C61;&#x7684;&#x72B6;&#x6001;&#x8FDB;&#x884C;&#x6539;&#x53D8;&#x90A3;</h3><p>&#x901A;&#x8FC7; $q &#x670D;&#x52A1;&#x7684; deffer &#x65B9;&#x6CD5;&#x5B9A;&#x4E49;&#x51FA;&#x6765;&#x4E00;&#x4E2A;&#x5EF6;&#x8FDF;&#x5BF9;&#x8C61;&#x3002;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/promise02.png" alt="deffer &#x65B9;&#x6CD5;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x5EF6;&#x8FDF;&#x5BF9;&#x8C61;"></p>
<p>&#x8FD9;&#x4E2A;&#x5EF6;&#x8FDF;&#x5BF9;&#x8C61;&#x90FD;&#x6709;&#x4E09;&#x4E2A;&#x65B9;&#x6CD5;</p>
<blockquote>
<p>resolved&#x65B9;&#x6CD5;&#xFF1A;&#x5F53;&#x6570;&#x636E;&#x8BF7;&#x6C42;&#x6210;&#x529F;&#x7684;&#x65F6;&#x5019;&#x8C03;&#x7528;&#xFF0C;&#x53C2;&#x6570;&#x662F;&#x6210;&#x529F;&#x8FD4;&#x56DE;&#x7684;&#x6570;&#x636E;&#x5BF9;&#x8C61;&#xFF0C;&#x628A; promise &#x5BF9;&#x8C61; Unfulfilled &#x72B6;&#x6001;&#x6539;&#x4E3A; fulfilled &#x72B6;&#x6001;&#x3002;<br>rejected&#x65B9;&#x6CD5;&#xFF1A;&#x5F53;&#x6570;&#x636E;&#x8BF7;&#x6C42;&#x5931;&#x8D25;&#x7684;&#x65F6;&#x5019;&#x8C03;&#x7528;&#xFF0C;&#x53C2;&#x6570;&#x662F;&#x5931;&#x8D25;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x628A; promise &#x5BF9;&#x8C61; Unfulfilled &#x72B6;&#x6001;&#x6539;&#x4E3A; failed &#x72B6;&#x6001;&#x3002;<br>&#x600E;&#x4E48;&#x77E5;&#x9053;&#x5728; promise &#x4E2D;&#x8C03;&#x7528;&#x54EA;&#x4E2A;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#xFF0C;&#x662F;&#x901A;&#x8FC7; promise &#x5BF9;&#x8C61;&#x7684;&#x72B6;&#x6001;&#x8FDB;&#x884C;&#x5224;&#x65AD;&#x7684;&#x3002;</p>
</blockquote>
<h3 id="Promise-A-&#x89C4;&#x8303;&#x8868;&#x73B0;&#x5F62;&#x5F0F;"><a href="#Promise-A-&#x89C4;&#x8303;&#x8868;&#x73B0;&#x5F62;&#x5F0F;" class="headerlink" title="Promise/A+&#x89C4;&#x8303;&#x8868;&#x73B0;&#x5F62;&#x5F0F;"></a>Promise/A+&#x89C4;&#x8303;&#x8868;&#x73B0;&#x5F62;&#x5F0F;</h3><p>1&#x3001;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x94FE;&#x5F0F;&#x7F16;&#x7A0B;&#x7684;&#x65B9;&#x5F0F;&#x5BF9;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x8FDB;&#x884C;&#x540C;&#x7EA7;&#x5904;&#x7406;<br>2&#x3001;&#x4E0A;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x7684;&#x8F93;&#x51FA;&#x503C;&#x662F;&#x4E0B;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x7684;&#x8F93;&#x5165;&#x503C;</p>
<h3 id="&#x5B8C;&#x6574;&#x4F7F;&#x7528;&#x8BF4;&#x660E;"><a href="#&#x5B8C;&#x6574;&#x4F7F;&#x7528;&#x8BF4;&#x660E;" class="headerlink" title="&#x5B8C;&#x6574;&#x4F7F;&#x7528;&#x8BF4;&#x660E;"></a>&#x5B8C;&#x6574;&#x4F7F;&#x7528;&#x8BF4;&#x660E;</h3><p>$http &#x914D;&#x5408; $q &#x7684;&#x4F7F;&#x7528;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line">angular.module(<span class="string">&quot;goodsList.service&quot;</span>, [])</div><div class="line">  .factory(<span class="string">&quot;GoodsListFty&quot;</span>, <span class="function"><span class="keyword">function</span> (<span class="params">$http, $q</span>) </span>{</div><div class="line">    <span class="keyword">return</span> {</div><div class="line">      <span class="attr">refreshData</span>: <span class="function"><span class="keyword">function</span> (<span class="params">typeNumber</span>) </span>{</div><div class="line">        <span class="comment">// 1.&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5EF6;&#x8FDF;&#x5BF9;&#x8C61;</span></div><div class="line">        <span class="keyword">var</span> deferred = $q.defer();</div><div class="line">        $http.get(<span class="string">&apos;data.json&apos;</span>).success(<span class="function"><span class="keyword">function</span> (<span class="params">data, header, config, status</span>)  </span>{</div><div class="line">          <span class="comment">// 2. &#x5F53;&#x8BF7;&#x6C42;&#x6210;&#x529F;&#x7684;&#x65F6;&#x5019;&#x7528; resolve &#x65B9;&#x6CD5;&#x8BF7;&#x6C42;&#x6570;&#x636E;</span></div><div class="line">          deferred.resolve(data);</div><div class="line">          <span class="built_in">console</span>.log(deferred);</div><div class="line">        }).error(<span class="function"><span class="keyword">function</span> (<span class="params">reason, header, config, status</span>) </span>{</div><div class="line">          <span class="comment">// 3. &#x5F53;&#x8BF7;&#x6C42;&#x5931;&#x8D25;&#x7684;&#x65F6;&#x5019;&#x7528; reject &#x65B9;&#x6CD5;&#x5904;&#x7406;&#x5931;&#x8D25;&#x539F;&#x56E0;</span></div><div class="line">          deferred.reject(reason);</div><div class="line">        });</div><div class="line">        <span class="comment">// 4. &#x8FD4;&#x56DE; promise &#x5BF9;&#x8C61;</span></div><div class="line">        <span class="keyword">return</span> deferred.promise;</div><div class="line">      }</div><div class="line">    };</div><div class="line">  });</div></pre></td></tr></table></figure>
<p>&#x5728;controller&#x4E2D;&#x4F7F;&#x7528;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// &#x5546;&#x54C1;&#x5217;&#x8868;&#x63A7;&#x5236;&#x5668;</span></div><div class="line">angular.module(<span class="string">&quot;goodsList.controller&quot;</span>, [<span class="string">&quot;goodsList.service&quot;</span>])</div><div class="line">  .controller(<span class="string">&quot;GoodsListCtrl&quot;</span>, <span class="function"><span class="keyword">function</span> (<span class="params">$scope, $stateParams, GoodsListFty</span>) </span>{</div><div class="line">    <span class="keyword">var</span> promise = GoodsListFty.refreshData($stateParams.typeNumber);</div><div class="line">    <span class="comment">// &#x7528; then &#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6570;&#x636E;</span></div><div class="line">    promise.then(<span class="function"><span class="keyword">function</span> (<span class="params">data</span>) </span>{</div><div class="line">      <span class="built_in">console</span>.log(data);</div><div class="line">    }).catch(<span class="function"><span class="keyword">function</span> (<span class="params">reason</span>) </span>{</div><div class="line">      <span class="built_in">console</span>.log(reason);</div><div class="line">    });</div><div class="line">  });</div></pre></td></tr></table></figure>
<h2 id="&#x4E0B;&#x62C9;&#x5237;&#x65B0;"><a href="#&#x4E0B;&#x62C9;&#x5237;&#x65B0;" class="headerlink" title="&#x4E0B;&#x62C9;&#x5237;&#x65B0;"></a>&#x4E0B;&#x62C9;&#x5237;&#x65B0;</h2><p>&#x4E2D;&#x6587;&#x6587;&#x6863;&#xFF1A;<a href="http://www.ionic.wang/js_doc-index-id-25.html" target="_blank" rel="external">http://www.ionic.wang/js_doc-index-id-25.html</a></p>
<h3 id="ion-refresher-&#x4ECB;&#x7ECD;"><a href="#ion-refresher-&#x4ECB;&#x7ECD;" class="headerlink" title="ion-refresher &#x4ECB;&#x7ECD;"></a>ion-refresher &#x4ECB;&#x7ECD;</h3><p>ion-refresher: &#x5FC5;&#x987B;&#x5728; ion-content &#x6807;&#x7B7E;&#x91CC;&#x9762;&#x4F7F;&#x7528;&#xFF0C;&#x800C;&#x4E14;&#x5FC5;&#x987B;&#x7D27;&#x6328;&#x7740; ion-content &#x6807;&#x7B7E;&#x3002;</p>
<h3 id="&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;"><a href="#&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;" class="headerlink" title="&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;"></a>&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;</h3><blockquote>
<p>&#x6DFB;&#x52A0;ion-refersher&#x6807;&#x7B7E;&#xFF0C;&#x7136;&#x540E;&#x914D;&#x7F6E;&#x91CC;&#x9762;&#x7684;&#x5C5E;&#x6027;<br>&#x5B9E;&#x73B0;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x89E6;&#x53D1;&#x7684;&#x65B9;&#x6CD5;<br>&#x5728;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x5B8C;&#x6BD5;&#x540E;&#x505C;&#x6B62;&#x5E7F;&#x64AD;</p>
</blockquote>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic34.png" alt="&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;"><br><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic35.png" alt="&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;"></p>
<h2 id="&#x4E0A;&#x62C9;&#x52A0;&#x8F7D;&#x66F4;&#x591A;"><a href="#&#x4E0A;&#x62C9;&#x52A0;&#x8F7D;&#x66F4;&#x591A;" class="headerlink" title="&#x4E0A;&#x62C9;&#x52A0;&#x8F7D;&#x66F4;&#x591A;"></a>&#x4E0A;&#x62C9;&#x52A0;&#x8F7D;&#x66F4;&#x591A;</h2><p><a href="http://www.ionic.wang/js_doc-index-id-29.html" target="_blank" rel="external">http://www.ionic.wang/js_doc-index-id-29.html</a></p>
<h3 id="ion-infinite-scroll-&#x4ECB;&#x7ECD;"><a href="#ion-infinite-scroll-&#x4ECB;&#x7ECD;" class="headerlink" title="ion-infinite-scroll &#x4ECB;&#x7ECD;"></a>ion-infinite-scroll &#x4ECB;&#x7ECD;</h3><p>&#x5FC5;&#x987B;&#x5728; ion-content &#x6807;&#x7B7E;&#x91CC;&#x9762;&#x4F7F;&#x7528;&#xFF0C;&#x800C;&#x4E14;&#x5FC5;&#x987B;&#x7D27;&#x6328;&#x7740; ion-content &#x6807;&#x7B7E;&#x3002;&#x5728;&#x5E95;&#x90E8;&#x3002;</p>
<h3 id="&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;-1"><a href="#&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;-1" class="headerlink" title="&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;"></a>&#x4F7F;&#x7528;&#x4ECB;&#x7ECD;</h3><blockquote>
<p>&#x6DFB;&#x52A0;ion-infinite-scroll&#x6807;&#x7B7E;&#xFF0C;&#x7136;&#x540E;&#x914D;&#x7F6E;&#x91CC;&#x9762;&#x7684;&#x5C5E;&#x6027;<br>&#x5B9E;&#x73B0;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x89E6;&#x53D1;&#x7684;&#x65B9;&#x6CD5;<br>&#x5728;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x5B8C;&#x6BD5;&#x540E;&#x505C;&#x6B62;&#x5E7F;&#x64AD;</p>
</blockquote>
<h3 id="emit-on"><a href="#emit-on" class="headerlink" title="$emit.$on"></a>$emit.$on</h3><p><a href="http://www.tuicool.com/articles/qIBNve" target="_blank" rel="external">http://www.tuicool.com/articles/qIBNve</a></p>
<h3 id="&#x751F;&#x547D;&#x5468;&#x671F;&#x7684;&#x95EE;&#x9898;"><a href="#&#x751F;&#x547D;&#x5468;&#x671F;&#x7684;&#x95EE;&#x9898;" class="headerlink" title="&#x751F;&#x547D;&#x5468;&#x671F;&#x7684;&#x95EE;&#x9898;"></a>&#x751F;&#x547D;&#x5468;&#x671F;&#x7684;&#x95EE;&#x9898;</h3><p>&#x5982;&#x679C;&#x5728; enter &#x65F6;&#x95F4;&#x4E2D;&#x6267;&#x884C;&#x5237;&#x65B0;&#x65B9;&#x6CD5;&#xFF0C;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x6570;&#x636E;&#x8FD8;&#x6CA1;&#x6709;&#x51FA;&#x6765;&#xFF0C;&#x53EF;&#x662F;&#x9875;&#x9762;&#x5DF2;&#x7ECF;&#x6E32;&#x67D3;&#xFF0C;&#x52A0;&#x8F7D;&#x66F4;&#x591A;&#x7684;&#x8DDD;&#x79BB;&#x5927;&#x4E8E; 1% &#x6240;&#x4EE5;&#x4F1A;&#x4E00;&#x76F4;&#x6267;&#x884C;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$scope.$on(<span class="string">&apos;$ionicView.enter&apos;</span>, <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>{</div><div class="line">    $scope.func_refreshGoodsList();</div><div class="line">});</div></pre></td></tr></table></figure>
<p>&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x8981;&#x653E;&#x5728;beforeEnter&#x4E8B;&#x4EF6;&#x4E2D;&#x6267;&#x884C;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$scope.$on(<span class="string">&apos;$ionicView.beforeEnter&apos;</span>, <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>{</div><div class="line">    $scope.func_refreshGoodsList();</div><div class="line">});</div></pre></td></tr></table></figure>
<h3 id="&#x6CA1;&#x6709;&#x6570;&#x636E;&#x63D0;&#x793A;&#x95EE;&#x9898;"><a href="#&#x6CA1;&#x6709;&#x6570;&#x636E;&#x63D0;&#x793A;&#x95EE;&#x9898;" class="headerlink" title="&#x6CA1;&#x6709;&#x6570;&#x636E;&#x63D0;&#x793A;&#x95EE;&#x9898;"></a>&#x6CA1;&#x6709;&#x6570;&#x636E;&#x63D0;&#x793A;&#x95EE;&#x9898;</h3><p>&#x8981;&#x6DFB;&#x52A0;&#x6CA1;&#x6709;&#x6570;&#x636E;&#x7684;&#x63D0;&#x793A;&#xFF0C;&#x5728;&#x5237;&#x65B0;&#x548C;&#x52A0;&#x8F7D;&#x7684;&#x65B9;&#x6CD5;&#x91CC;&#x9762;&#x8981;&#x5BF9;&#x8FD4;&#x56DE;&#x6765;&#x7684; result &#x6570;&#x636E;&#x8FDB;&#x884C;&#x975E;&#x7A7A;&#x5224;&#x65AD;&#xFF0C;&#x7136;&#x540E;&#x4FEE;&#x6539; pms_isMoreItemsAvailable &#x7684;&#x503C;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">ng-hide</span>=<span class="string">&quot;pms_isMoreItemsAvailable&quot;</span> <span class="attr">style</span>=<span class="string">&quot;text-align: center&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">span</span>&gt;</span>&#x6211;&#x53BB;&#xFF0C;&#x5730;&#x4E3B;&#x5BB6;&#x4E5F;&#x6CA1;&#x6709;&#x4F59;&#x7CAE;&#x554A;&#xFF01;<span class="tag">&lt;/<span class="name">span</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="&#x5FAA;&#x73AF;&#x52A0;&#x8F7D;&#x7684;&#x95EE;&#x9898;"><a href="#&#x5FAA;&#x73AF;&#x52A0;&#x8F7D;&#x7684;&#x95EE;&#x9898;" class="headerlink" title="&#x5FAA;&#x73AF;&#x52A0;&#x8F7D;&#x7684;&#x95EE;&#x9898;"></a>&#x5FAA;&#x73AF;&#x52A0;&#x8F7D;&#x7684;&#x95EE;&#x9898;</h3><p>&#x901A;&#x8FC7; ng-if &#x65B9;&#x6CD5;&#x6765;&#x63A7;&#x5236;&#x52A0;&#x8F7D;&#x66F4;&#x591A;&#x7684;&#x65E0;&#x9650;&#x5FAA;&#x73AF;&#xFF0C;&#x9ED8;&#x8BA4; pms_isMoreItemsAvailable=true</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">ion-infinite-scroll</span> <span class="attr">ng-if</span>=<span class="string">&quot;pms_isMoreItemsAvailable&quot;</span> <span class="attr">on-infinite</span>=<span class="string">&quot;func_loadMoreGoodsList()&quot;</span> <span class="attr">distance</span>=<span class="string">&quot;1%&quot;</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">ion-infinite-scroll</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="&#x906E;&#x7F69;&#x5C42;"><a href="#&#x906E;&#x7F69;&#x5C42;" class="headerlink" title="&#x906E;&#x7F69;&#x5C42;"></a>&#x906E;&#x7F69;&#x5C42;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ionicLoading.show({</div><div class="line">  <span class="attr">template</span>: <span class="string">&quot;&#x6B63;&#x5728;&#x8F7D;&#x5165;&#x6570;&#x636E;&#xFF0C;&#x8BF7;&#x7A0D;&#x540E;...&quot;</span></div><div class="line">});</div></pre></td></tr></table></figure>
<p>&#x5728;&#x5E7F;&#x64AD;&#x5B8C;&#x6BD5;&#x4E4B;&#x540E;&#x6267;&#x884C;&#x53D6;&#x6D88;&#x906E;&#x7F69;&#x5C42;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">setTimeout(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">  $ionicLoading.hide();</div><div class="line">},<span class="number">1000</span>);</div></pre></td></tr></table></figure>
<h2 id="IndexedDb"><a href="#IndexedDb" class="headerlink" title="IndexedDb"></a>IndexedDb</h2><h3 id="&#x7B80;&#x4ECB;"><a href="#&#x7B80;&#x4ECB;" class="headerlink" title="&#x7B80;&#x4ECB;"></a>&#x7B80;&#x4ECB;</h3><p>indexedDB &#x662F; HTML5-WebStorage &#x7684;&#x91CD;&#x8981;&#x4E00;&#x73AF;&#xFF0C;&#x662F;&#x4E00;&#x79CD;&#x8F7B;&#x91CF;&#x7EA7; NOSQL &#x6570;&#x636E;&#x5E93;&#x3002;&#x76F8;&#x6BD4; web sql(sqlite) &#x66F4;&#x52A0;&#x9AD8;&#x6548;&#xFF0C;&#x5305;&#x62EC;&#x7D22;&#x5F15;&#x3001;&#x4E8B;&#x52A1;&#x5904;&#x7406;&#x548C;&#x5065;&#x58EE;&#x7684;&#x67E5;&#x8BE2;&#x529F;&#x80FD;&#x3002;</p>
<h3 id="&#x548C;-webSQL-&#x7684;&#x6BD4;&#x8F83;"><a href="#&#x548C;-webSQL-&#x7684;&#x6BD4;&#x8F83;" class="headerlink" title="&#x548C; webSQL &#x7684;&#x6BD4;&#x8F83;"></a>&#x548C; webSQL &#x7684;&#x6BD4;&#x8F83;</h3><blockquote>
<p>&#x5141;&#x8BB8;&#x5FEB;&#x901F;&#x7D22;&#x5F15;&#x548C;&#x641C;&#x7D22;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x6240;&#x4EE5;&#x5728; HTML5 &#x7684; web &#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x6709;&#x6548;&#x7BA1;&#x7406;&#x4F60;&#x7684;&#x6570;&#x636E;&#x548C;&#x9AD8;&#x6548;&#x7387;&#x7684;&#x8BFB;/&#x5199;&#x64CD;&#x4F5C;&#x3002;<br>W3C&#x4E3B;&#x63A8;&#x7684;&#x79BB;&#x7EBF;&#x6570;&#x636E;&#x5E93;&#x7C7B;&#x578B;&#xFF0C;&#x9010;&#x6E10;&#x66FF;&#x4EE3; Web SQL &#x7C7B;&#x578B;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x66F4;&#x65B0;&#x6548;&#x7387;&#x9AD8;&#x5E76;&#x4E0D;&#x65AD;&#x5B8C;&#x5584;&#x3002;<br>&#x5DE5;&#x4F5C;&#x5728;&#x5F02;&#x6B65;&#x6A21;&#x5F0F;&#x4E0B;&#x6267;&#x884C;&#x6BCF;&#x6B65;&#x64CD;&#x4F5C;&#x3002;&#x4F7F;&#x7528;&#x9AD8;&#x6548;&#x7387;&#x7684;&#x7684; JavaScript &#x4E8B;&#x4EF6;&#x9A71;&#x52A8;&#x6A21;&#x5757;</p>
</blockquote>
<h2 id="&#x64CD;&#x4F5C;-indexedDB"><a href="#&#x64CD;&#x4F5C;-indexedDB" class="headerlink" title="&#x64CD;&#x4F5C; indexedDB"></a>&#x64CD;&#x4F5C; indexedDB</h2><p>&#x539F;&#x7406;&#x4EE3;&#x7801;&#xFF1A;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>indexedDB &#x4F7F;&#x7528;<span class="tag">&lt;/<span class="name">title</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="javascript"></span></div><div class="line">  <span class="comment">// &#x83B7;&#x53D6;indexdb&#x5BF9;&#x8C61;,&#x4E3A;&#x4E86;&#x517C;&#x5BB9;&#x6027;&#x7684;&#x5199;&#x6CD5;</span></div><div class="line">  <span class="comment">// 1&#x3001;&#x83B7;&#x53D6;&#x5BF9;&#x8C61;</span></div><div class="line">  <span class="built_in">window</span>.indexedDB = <span class="built_in">window</span>.indexedDB || <span class="built_in">window</span>.mozIndexedDB || <span class="built_in">window</span>.webkitIndexedDB || <span class="built_in">window</span>.msIndexedDB;</div><div class="line">  <span class="built_in">window</span>.IDBTransaction = <span class="built_in">window</span>.IDBTransaction || <span class="built_in">window</span>.webkitIDBTransaction || <span class="built_in">window</span>.msIDBTransaction;</div><div class="line">  <span class="built_in">window</span>.IDBKeyRange = <span class="built_in">window</span>.IDBKeyRange || <span class="built_in">window</span>.webkitIDBKeyRange || <span class="built_in">window</span>.msIDBKeyRange;</div><div class="line">  <span class="built_in">window</span>.IDBCursor = <span class="built_in">window</span>.IDBCursor || <span class="built_in">window</span>.webkitIDBCursor || <span class="built_in">window</span>.msIDBCursor;</div><div class="line">  </div><div class="line">  <span class="comment">// 2&#x3001;&#x5B9A;&#x4E49;&#x6570;&#x636E;&#x5E93;&#x7684;&#x57FA;&#x672C;&#x4FE1;&#x606F;</span></div><div class="line">  <span class="keyword">var</span> dbInfo = {</div><div class="line">    <span class="attr">dbName</span>: <span class="string">&apos;aptdb&apos;</span>,</div><div class="line">    <span class="attr">dbVersion</span>: <span class="number">2021</span>, <span class="comment">//&#x7528;&#x5C0F;&#x6570;&#x4F1A;&#x56DB;&#x820D;&#x4E94;&#x5165;&#xFF0C;&#x7248;&#x672C;&#x53F7;&#x53EA;&#x80FD;&#x8D8A;&#x6765;&#x8D8A;&#x5927;</span></div><div class="line">    dbInstance: {}</div><div class="line">  };</div><div class="line"></div><div class="line">  <span class="comment">// 3&#x3001;&#x521B;&#x5EFA;&#x6570;&#x636E;&#x5E93;</span></div><div class="line">  <span class="keyword">var</span> dbContent = <span class="built_in">window</span>.indexedDB.open(dbInfo.dbName, dbInfo.dbVersion);</div><div class="line">  <span class="comment">// &#x5224;&#x65AD;&#x6570;&#x636E;&#x5E93;&#x7248;&#x672C;&#x53F7;&#x662F;&#x5426;&#x66F4;&#x65B0;&#xFF0C;&#x66F4;&#x52A0; dbversion &#x548C; dbname &#x53BB;&#x5224;&#x65AD;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x53D1;&#x9001;&#x53D8;&#x5316;&#xFF0C;&#x5C31;&#x4E0D;&#x8D70;&#x8FD9;&#x4E2A;&#x56DE;&#x8C03;&#x65B9;&#x6CD5;&#xFF08;&#x521B;&#x5EFA;&#x548C;&#x4FEE;&#x6539;&#x8868;&#x7ED3;&#x6784;&#x5728;&#x8FD9;&#x91CC;&#x64CD;&#x4F5C;&#xFF09;</span></div><div class="line">  <span class="comment">// &#x5982;&#x679C;&#x6570;&#x636E;&#x5E93;&#x540D;&#x79F0;&#x548C;&#x7248;&#x672C;&#x53F7;&#x76F8;&#x540C;&#xFF0C;&#x90A3;&#x4E48;&#x8BE5;&#x65B9;&#x6CD5;&#x53EA;&#x6267;&#x884C;&#x4E00;&#x6B21;</span></div><div class="line">  dbContent.onupgradeneeded = <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>{</div><div class="line">    <span class="built_in">console</span>.log(e);</div><div class="line">    <span class="comment">// 4&#x3001;&#x521B;&#x5EFA;&#x6570;&#x636E;&#x5E93; store(&#x8868;)</span></div><div class="line">    <span class="keyword">var</span> _db = e.target.result;</div><div class="line">    <span class="comment">// &#x4FDD;&#x5B58;&#x8868;&#x540D;&#x79F0;&#x7684;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;</span></div><div class="line">    <span class="keyword">var</span> storeNames = _db.objectStoreNames;</div><div class="line">    <span class="keyword">if</span> (!storeNames.contains(<span class="string">&quot;cart&quot;</span>)) {</div><div class="line">      <span class="comment">// &#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x8868;&#x7ED3;&#x6784;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x8868;&#x540D;&#x79F0;</span></div><div class="line">      _db.createObjectStore(<span class="string">&quot;cart&quot;</span>, {</div><div class="line">        <span class="comment">// &#x5FC5;&#x987B;&#x6709;&#x4E2A; keyPath &#x5C5E;&#x6027;&#xFF0C;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x503C;&#x5FC5;&#x987B;&#x662F;&#x80FD;&#x552F;&#x4E00;&#x6807;&#x8BC6;&#x8FD9;&#x6761;&#x6570;&#x636E;&#x7684;&#x503C;&#x7684;&#x5B57;&#x6BB5;</span></div><div class="line">        keyPath: <span class="string">&quot;goodsId&quot;</span>, <span class="comment">//&#x76F8;&#x5F53;&#x4E8E;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x7684;&#x4E3B;&#x952E;</span></div><div class="line">        autoIncrement: <span class="literal">true</span></div><div class="line">      });</div><div class="line">    }</div><div class="line">  };</div><div class="line"></div><div class="line">  <span class="comment">// &#x6253;&#x5F00;&#x6570;&#x636E;&#x5E93;&#x6210;&#x529F;&#x7684;&#x56DE;&#x8C03;&#x51FD;&#x6570;</span></div><div class="line">  dbContent.onsuccess = <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>{</div><div class="line">    <span class="comment">// 5&#x3001;&#x589E;&#x5220;&#x6539;&#x67E5;&#x64CD;&#x4F5C;&#xFF0C;&#x5F00;&#x542F;&#x4E8B;&#x7269;&#xFF0C;&#x6BCF;&#x6B21;&#x53EA;&#x80FD;&#x505A;&#x4E00;&#x4EF6;&#x4E8B;&#x60C5;</span></div><div class="line">    <span class="keyword">var</span> _db = e.target.result;</div><div class="line">    <span class="comment">// &#x521B;&#x5EFA;&#x4E8B;&#x7269;</span></div><div class="line">    <span class="keyword">var</span> trans = _db.transaction([<span class="string">&quot;cart&quot;</span>], <span class="string">&quot;readwrite&quot;</span>);</div><div class="line">    <span class="comment">// &#x7528;&#x4E8B;&#x7269;&#x83B7;&#x53D6;&#x8868;</span></div><div class="line">    <span class="keyword">var</span> store = trans.objectStore(<span class="string">&quot;cart&quot;</span>);</div><div class="line"></div><div class="line">    <span class="comment">// &#x867D;&#x7136;&#x53EF;&#x4EE5;&#x5728;&#x4E00;&#x6B21;&#x6210;&#x529F;&#x6253;&#x5F00;&#x8BF7;&#x6C42;&#x7684;&#x64CD;&#x4F5C;&#x4E2D;&#x540C;&#x65F6;&#x64CD;&#x4F5C;&#x591A;&#x6B21;&#x589E;&#x5220;&#x6539;&#x67E5;&#x547D;&#x4EE4;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x63A8;&#x8350;&#xFF0C;&#x4EE5;&#x4E3A;&#x8FD9;&#x6837;&#x524D;&#x9762;&#x7684;&#x64CD;&#x4F5C;&#x5C31;&#x4E0D;&#x80FD;&#x88AB;&#x76D1;&#x542C;&#x5230;&#x4E86;</span></div><div class="line">    <span class="comment">// &#x589E;&#x52A0;&#x6570;&#x636E;</span></div><div class="line">    <span class="keyword">var</span> req = store.add({</div><div class="line">      <span class="attr">goodsId</span>: <span class="string">&apos;df6&apos;</span>,</div><div class="line">      <span class="attr">prise</span>: <span class="number">12.3</span>,</div><div class="line">      <span class="attr">name</span>: <span class="string">&quot;&#x8863;&#x670D;&quot;</span>,</div><div class="line">      <span class="attr">size</span>: <span class="string">&quot;M&quot;</span>,</div><div class="line">      <span class="attr">age</span>: <span class="number">99</span></div><div class="line">    })</div><div class="line"></div><div class="line">    <span class="comment">// &#x4FEE;&#x6539;&#x6570;&#x636E;</span></div><div class="line">    <span class="comment">// var req = store.put({</span></div><div class="line">    <span class="comment">//   goodsId: &apos;df6&apos;,</span></div><div class="line">    <span class="comment">//   prise: 12.79,</span></div><div class="line">    <span class="comment">//   name: &quot;&#x8863;&#x670D;&quot;,</span></div><div class="line">    <span class="comment">//   size: &quot;L&quot;,</span></div><div class="line">    <span class="comment">//   age: 1000</span></div><div class="line">    <span class="comment">// }</span></div><div class="line"></div><div class="line">   <span class="comment">// &#x5220;&#x9664;&#x6570;&#x636E;</span></div><div class="line">    <span class="comment">// var req = store.delete(&quot;df6&quot;);</span></div><div class="line"></div><div class="line">    <span class="comment">// &#x67E5;&#x8BE2;&#x6570;&#x636E;</span></div><div class="line">    <span class="comment">// var req = store.get(&quot;df1&quot;);</span></div><div class="line"></div><div class="line">    <span class="comment">// &#x5220;&#x9664;&#x6240;&#x6709;&#x6570;&#x636E;</span></div><div class="line">    <span class="comment">// var req = store.clear();</span></div><div class="line"></div><div class="line">    <span class="comment">// &#x6570;&#x636E;&#x64CD;&#x4F5C;&#x6210;&#x529F;&#x56DE;&#x8C03;&#x51FD;&#x6570;</span></div><div class="line">    <span class="comment">// req.onsuccess = function(e){</span></div><div class="line">    <span class="comment">//   console.log(&apos;&#x6570;&#x636E;&#x64CD;&#x4F5C;&#x6210;&#x529F;&#x4E86;&apos;);</span></div><div class="line">    <span class="comment">// }</span></div><div class="line">    </div><div class="line">    <span class="comment">// &#x6570;&#x636E;&#x6DFB;&#x52A0;&#x5931;&#x8D25;&#x56DE;&#x8C03;&#x51FD;&#x6570;  </span></div><div class="line">    <span class="comment">// req.onerror = function(e){</span></div><div class="line">    <span class="comment">//   console.log(&apos;&#x6570;&#x636E;&#x64CD;&#x4F5C;&#x5931;&#x8D25;&#x4E86;&apos;);</span></div><div class="line">    <span class="comment">// }</span></div><div class="line"></div><div class="line">    <span class="comment">// &#x67E5;&#x8BE2;&#x6240;&#x6709;&#x6570;&#x636E;&#xFF08;&#x7528;&#x4E86;&#x6E38;&#x6807;&#xFF09;</span></div><div class="line">    <span class="keyword">var</span> cursor = store.openCursor();</div><div class="line">    <span class="keyword">var</span> data = [];</div><div class="line">    cursor.onsuccess = <span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span>{</div><div class="line">      <span class="keyword">var</span> result = e.target.result;</div><div class="line">      <span class="keyword">if</span> (result &amp;&amp; result !== <span class="literal">null</span>) {</div><div class="line">        data.push(result.value);</div><div class="line">        <span class="comment">// &#x91CD;&#x65B0;&#x6267;&#x884C; onsuccess &#x53E5;&#x67C4;&#xFF0C;&#x5FC5;&#x987B;&#x5F97;&#x5199;&#x8FD9;&#x53E5;</span></div><div class="line">        result.continue();</div><div class="line">      }</div><div class="line">      <span class="built_in">console</span>.log(data);</div><div class="line">    };</div><div class="line">    cursor.onerror = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">    }</div><div class="line">  };</div><div class="line"></div><div class="line">  <span class="comment">// &#x6253;&#x5F00;&#x6570;&#x636E;&#x5E93;&#x8BF7;&#x6C42;&#x5931;&#x8D25;&#x7684;&#x56DE;&#x8C03;&#x51FD;&#x6570;</span></div><div class="line">  dbContent.onerror = <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>{</div><div class="line">    <span class="built_in">console</span>.log(<span class="number">3</span>);</div><div class="line">  }</div><div class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<p>&#x5C01;&#x88C5;&#x4EE3;&#x7801;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div></pre></td><td class="code"><pre><div class="line">angular.module(<span class="string">&apos;indexeddb&apos;</span>, [])</div><div class="line">.factory(<span class="string">&apos;IndexeddbJs&apos;</span>, [<span class="string">&apos;$ionicPopup&apos;</span>,<span class="function"><span class="keyword">function</span> (<span class="params">$ionicPopup</span>) </span>{</div><div class="line"></div><div class="line">  <span class="built_in">window</span>.indexedDB = <span class="built_in">window</span>.indexedDB || <span class="built_in">window</span>.mozIndexedDB || <span class="built_in">window</span>.webkitIndexedDB || <span class="built_in">window</span>.msIndexedDB;</div><div class="line">  <span class="built_in">window</span>.IDBTransaction = <span class="built_in">window</span>.IDBTransaction || <span class="built_in">window</span>.webkitIDBTransaction || <span class="built_in">window</span>.msIDBTransaction;</div><div class="line">  <span class="built_in">window</span>.IDBKeyRange = <span class="built_in">window</span>.IDBKeyRange || <span class="built_in">window</span>.webkitIDBKeyRange || <span class="built_in">window</span>.msIDBKeyRange;</div><div class="line">  <span class="built_in">window</span>.IDBCursor=<span class="built_in">window</span>.IDBCursor||<span class="built_in">window</span>.webkitIDBCursor|| <span class="built_in">window</span>.msIDBCursor;</div><div class="line"></div><div class="line">  <span class="keyword">var</span> db={</div><div class="line">    <span class="attr">dbName</span>: <span class="string">&apos;aptdb&apos;</span>,</div><div class="line">    <span class="attr">dbVersion</span>: <span class="number">2089</span>, <span class="comment">//&#x7528;&#x5C0F;&#x6570;&#x4F1A;&#x56DB;&#x820D;&#x4E94;&#x5165;</span></div><div class="line">    dbInstance: {},</div><div class="line"></div><div class="line">    <span class="attr">errorHandler</span>: <span class="function"><span class="keyword">function</span> (<span class="params">error</span>) </span>{</div><div class="line">      <span class="built_in">console</span>.log(<span class="string">&apos;error: &apos;</span> + error.target.error.message);</div><div class="line">    },</div><div class="line"></div><div class="line">    <span class="comment">// &#x6253;&#x5F00;&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;</span></div><div class="line">    open: <span class="function"><span class="keyword">function</span> (<span class="params">func, fail</span>) </span>{</div><div class="line">      <span class="keyword">var</span> dbContent = <span class="built_in">window</span>.indexedDB.open(db.dbName, db.dbVersion);</div><div class="line">      <span class="comment">// &#x6570;&#x636E;&#x5E93;&#x6253;&#x5F00;&#x8BF7;&#x6C42;&#x7684;&#x8DDF;&#x65B0;&#x56DE;&#x8C03;&#x51FD;&#x6570;</span></div><div class="line">      dbContent.onupgradeneeded = db.upgrade;</div><div class="line">      <span class="comment">// &#x6570;&#x636E;&#x5E93;&#x6253;&#x5F00;&#x8BF7;&#x6C42;&#x7684;&#x5931;&#x8D25;&#x56DE;&#x8C03;&#x51FD;&#x6570;</span></div><div class="line">      dbContent.onerror = db.errorHandler;</div><div class="line">      <span class="comment">// &#x6570;&#x636E;&#x5E93;&#x6253;&#x5F00;&#x8BF7;&#x6C42;&#x7684;&#x6210;&#x529F;&#x56DE;&#x8C03;&#x51FD;&#x6570;</span></div><div class="line">      dbContent.onsuccess = <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>{</div><div class="line">        db.dbInstance = dbContent.result;</div><div class="line">        db.dbInstance.onerror = fail;</div><div class="line">        func();</div><div class="line">      };</div><div class="line">    },</div><div class="line">    <span class="comment">// &#x6570;&#x636E;&#x5E93;&#x7248;&#x672C;&#x8DDF;&#x65B0;&#x64CD;&#x4F5C;</span></div><div class="line">    upgrade: <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>{</div><div class="line">      <span class="keyword">var</span> _db = e.target.result,names = _db.objectStoreNames;</div><div class="line">      <span class="comment">// &#x6B64;&#x5904;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x591A;&#x4E2A;&#x8868;</span></div><div class="line">      <span class="keyword">var</span> name = <span class="string">&quot;cart&quot;</span>;</div><div class="line">      <span class="keyword">if</span> (!names.contains(name)) {</div><div class="line">        <span class="comment">// &#x521B;&#x5EFA;&#x8868;</span></div><div class="line">        _db.createObjectStore(</div><div class="line">          name,</div><div class="line">          {</div><div class="line">            <span class="attr">keyPath</span>: <span class="string">&apos;goodsId&apos;</span>,</div><div class="line">            <span class="attr">autoIncrement</span>: <span class="literal">false</span></div><div class="line">          });</div><div class="line">      }</div><div class="line">    },</div><div class="line">    <span class="comment">// &#x83B7;&#x53D6;&#x8868;&#x5BF9;&#x8C61;</span></div><div class="line">    getObjectStore: <span class="function"><span class="keyword">function</span> (<span class="params">objectStoreName, mode</span>) </span>{</div><div class="line">      <span class="keyword">var</span> txn, store;</div><div class="line">      mode = mode || <span class="string">&apos;readonly&apos;</span>;</div><div class="line">      txn = db.dbInstance.transaction([objectStoreName], mode);</div><div class="line">      store = txn.objectStore(objectStoreName);</div><div class="line">      <span class="keyword">return</span> store;</div><div class="line">    },</div><div class="line">    <span class="comment">// &#x589E;&#x52A0;&#x6570;&#x636E;&#x65B9;&#x6CD5;</span></div><div class="line">    add: <span class="function"><span class="keyword">function</span> (<span class="params">objectStoreName, data, success, fail</span>) </span>{</div><div class="line">      db.open(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">        <span class="keyword">var</span> store, req, mode = <span class="string">&apos;readwrite&apos;</span>;</div><div class="line">          store = db.getObjectStore(objectStoreName, mode);</div><div class="line">          req = store.add(data);</div><div class="line">          req.onsuccess = success;</div><div class="line">          req.onerror=fail;</div><div class="line">      },fail);</div><div class="line">    },</div><div class="line">    <span class="comment">// &#x4FEE;&#x6539;&#x6570;&#x636E;&#x65B9;&#x6CD5;</span></div><div class="line">    update: <span class="function"><span class="keyword">function</span> (<span class="params">objectStoreName, data, success, fail</span>) </span>{</div><div class="line">      db.open(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">        <span class="keyword">var</span> store, req, mode = <span class="string">&apos;readwrite&apos;</span>;</div><div class="line">        store = db.getObjectStore(objectStoreName,mode);</div><div class="line">        req = store.put(data);</div><div class="line">        req.onsuccess = success;</div><div class="line">        req.onerror=fail;</div><div class="line">      },fail);</div><div class="line">    },</div><div class="line">    <span class="comment">// &#x83B7;&#x53D6;&#x5168;&#x90E8;&#x6570;&#x636E;&#x65B9;&#x6CD5;</span></div><div class="line">    getAll: <span class="function"><span class="keyword">function</span> (<span class="params">objectStoreName, success, fail</span>) </span>{</div><div class="line">      db.open(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">        <span class="keyword">var</span> store = db.getObjectStore(objectStoreName), cursor = store.openCursor(), data = [];</div><div class="line">        cursor.onsuccess = <span class="function"><span class="keyword">function</span> (<span class="params">e</span>) </span>{</div><div class="line">          <span class="keyword">var</span> result = e.target.result;</div><div class="line">          <span class="keyword">if</span> (result &amp;&amp; result !== <span class="literal">null</span>) {</div><div class="line">            data.push(result.value);</div><div class="line">            result.continue();</div><div class="line">          } <span class="keyword">else</span> {</div><div class="line">            success(data);</div><div class="line">          }</div><div class="line">        };</div><div class="line">        cursor.onerror=fail;</div><div class="line">      },fail);</div><div class="line">    },</div><div class="line">    <span class="comment">// &#x83B7;&#x53D6;&#x5355;&#x6761;&#x6570;&#x636E;&#x65B9;&#x6CD5;</span></div><div class="line">    get: <span class="function"><span class="keyword">function</span> (<span class="params">id, objectStoreName, success, fail</span>) </span>{</div><div class="line">      db.open(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">        <span class="keyword">var</span> store = db.getObjectStore(objectStoreName), req = store.get(id);</div><div class="line">          req.onsuccess = <span class="function"><span class="keyword">function</span> (<span class="params">e</span>)</span>{</div><div class="line">            success(e.target.result);</div><div class="line">        };</div><div class="line">        req.onerror=fail;</div><div class="line">      });</div><div class="line">    },</div><div class="line">    <span class="comment">// delete&#x662F;&#x4FDD;&#x7559;&#x5B57;</span></div><div class="line">    <span class="comment">// &#x5220;&#x9664;&#x6570;&#x636E;&#x65B9;&#x6CD5;</span></div><div class="line">    <span class="string">&apos;delete&apos;</span>: <span class="function"><span class="keyword">function</span> (<span class="params">id, objectStoreName, success, fail</span>) </span>{</div><div class="line">      db.open(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">        <span class="keyword">var</span> mode = <span class="string">&apos;readwrite&apos;</span>, store, req;</div><div class="line">        store = db.getObjectStore(objectStoreName, mode);</div><div class="line">        req = store.delete(id);</div><div class="line">        req.onsuccess = success;</div><div class="line">        req.onerror=fail;</div><div class="line">      });</div><div class="line">    },</div><div class="line">    <span class="comment">// &#x5220;&#x9664;&#x8868;&#x6570;&#x636E;&#x65B9;&#x6CD5;</span></div><div class="line">    deleteAll: <span class="function"><span class="keyword">function</span> (<span class="params">objectStoreName, success, fail</span>) </span>{</div><div class="line">      db.open(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">        <span class="keyword">var</span> mode, store, req;</div><div class="line">        mode = <span class="string">&apos;readwrite&apos;</span>;</div><div class="line">        store = db.getObjectStore(objectStoreName, mode);</div><div class="line">        req = store.clear();</div><div class="line">        req.onsuccess = success;</div><div class="line">        req.onerror=fail;</div><div class="line">      });</div><div class="line">    }</div><div class="line">  };</div><div class="line">  <span class="keyword">return</span> db;</div><div class="line">}]);</div></pre></td></tr></table></figure>
<h2 id="ng-cordova"><a href="#ng-cordova" class="headerlink" title="ng-cordova"></a>ng-cordova</h2><h3 id="&#x5B98;&#x7F51;"><a href="#&#x5B98;&#x7F51;" class="headerlink" title="&#x5B98;&#x7F51;"></a>&#x5B98;&#x7F51;</h3><p><a href="http://ngcordova.com/docs/" target="_blank" rel="external">http://ngcordova.com/docs/</a></p>
<h3 id="&#x4F7F;&#x7528;&#x6B65;&#x9AA4;"><a href="#&#x4F7F;&#x7528;&#x6B65;&#x9AA4;" class="headerlink" title="&#x4F7F;&#x7528;&#x6B65;&#x9AA4;"></a>&#x4F7F;&#x7528;&#x6B65;&#x9AA4;</h3><p>&#x4E0B;&#x8F7D; ng-cordova &#x7684;js&#x6587;&#x4EF6;</p>
<p>&#x5728;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x9762;&#x6253;&#x5F00;&#x547D;&#x4EE4;&#x7A97;&#x53E3;&#xFF0C;&#x8F93;&#x5165;</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ bower install ngCordova -save</div></pre></td></tr></table></figure>
<p>&#x5728;index.html&#x6587;&#x4EF6;&#x4E2D;&#x5F15;&#x5165; ng-cordova.js &#x6587;&#x4EF6;</p>
<p>&#x5728;app.js(&#x9879;&#x76EE;&#x5165;&#x53E3;&#x4E2D;)&#x5F15;&#x5165;&#x4F9D;&#x8D56;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">angular.module(<span class="string">&apos;myApp&apos;</span>, [<span class="string">&apos;ngCordova&apos;</span>]);</div></pre></td></tr></table></figure>
<p>&#x5728; $ionicPlatform.ready &#x4E8B;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;&#x63D2;&#x4EF6;&#x529F;&#x80FD;&#xFF0C;&#x5C31;&#x662F;&#x5F00;&#x59CB;&#x4F7F;&#x7528;&#x6211;&#x4EEC;&#x7684;&#x63D2;&#x4EF6;</p>
<p>&#x4E0B;&#x8F7D;&#x76F8;&#x5E94;&#x529F;&#x80FD;&#x7684;&#x63D2;&#x4EF6;&#xFF0C;&#x6309;&#x7167;&#x5B98;&#x65B9;&#x6587;&#x6863;&#x4F7F;&#x7528;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;</p>
<p>&#x5728;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x9762;&#x6253;&#x5F00;&#x547D;&#x4EE4;&#x7A97;&#x53E3;</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">cordova plugin add [&#x63D2;&#x4EF6;&#x540D;&#x79F0;]</div></pre></td></tr></table></figure>
<p>&#x6BD4;&#x5982;&#xFF1A;</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">cordova plugin add cordova-plugin-camera</div></pre></td></tr></table></figure>
<h2 id="&#x8C03;&#x7528;&#x624B;&#x673A;&#x6444;&#x50CF;&#x5934;&#x529F;&#x80FD;&#x4FDD;&#x5B58;&#x5934;&#x50CF;"><a href="#&#x8C03;&#x7528;&#x624B;&#x673A;&#x6444;&#x50CF;&#x5934;&#x529F;&#x80FD;&#x4FDD;&#x5B58;&#x5934;&#x50CF;" class="headerlink" title="&#x8C03;&#x7528;&#x624B;&#x673A;&#x6444;&#x50CF;&#x5934;&#x529F;&#x80FD;&#x4FDD;&#x5B58;&#x5934;&#x50CF;"></a>&#x8C03;&#x7528;&#x624B;&#x673A;&#x6444;&#x50CF;&#x5934;&#x529F;&#x80FD;&#x4FDD;&#x5B58;&#x5934;&#x50CF;</h2><p>&#x8C03;&#x7528; actionsheet</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// &#x6211;&#x7684;&#x9875;&#x9762;</span></div><div class="line">angular.module(<span class="string">&apos;account.controller&apos;</span>, [<span class="string">&apos;account.service&apos;</span>])</div><div class="line">  .controller(<span class="string">&apos;AccountCtrl&apos;</span>, <span class="function"><span class="keyword">function</span> (<span class="params">$scope, $window, AccountFty, $ionicPopup, $ionicActionSheet, $cordovaCamera</span>) </span>{</div><div class="line"></div><div class="line">    <span class="comment">// &#x5728;&#x6BCF;&#x6B21;&#x8FDB;&#x5165;&#x63A7;&#x5236;&#x5668;&#x7684;&#x65F6;&#x5019;&#x68C0;&#x67E5; localstorage &#x662F;&#x5426;&#x6709;&#x5934;&#x50CF;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x5982;&#x679C;&#x6709;&#xFF0C;&#x628A;&#x6570;&#x636E;&#x8D4B;&#x503C;&#x7ED9;&#x56FE;&#x7247; img &#x7684; src &#x5C5E;&#x6027;</span></div><div class="line">    <span class="keyword">if</span> (localStorage[<span class="string">&quot;touxiang&quot;</span>]) {</div><div class="line">      <span class="keyword">var</span> image = <span class="built_in">document</span>.getElementById(<span class="string">&apos;touxiang&apos;</span>);</div><div class="line">      image.src = <span class="string">&quot;data:image/jpeg;base64,&quot;</span> + localStorage[<span class="string">&quot;touxiang&quot;</span>];</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">// &#x8C03;&#x7528;&#x6444;&#x50CF;&#x5934;&#x529F;&#x80FD;</span></div><div class="line">    $scope.func_showAction = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line"></div><div class="line">      <span class="comment">// &#x663E;&#x793A;&#x64CD;&#x4F5C;&#x8868;</span></div><div class="line">      $ionicActionSheet.show({</div><div class="line">        <span class="attr">buttons</span>: [</div><div class="line">          {<span class="attr">text</span>: <span class="string">&apos;&#x7167;&#x76F8;&#x673A;&apos;</span>},</div><div class="line">          {<span class="attr">text</span>: <span class="string">&apos;&#x56FE;&#x5E93;&apos;</span>}</div><div class="line">        ],</div><div class="line">        <span class="attr">titleText</span>: <span class="string">&apos;&#x8BF7;&#x9009;&#x62E9;&#x6587;&#x4EF6;&#x6E90;&apos;</span>,</div><div class="line">        <span class="attr">cancelText</span>: <span class="string">&apos;&#x53D6;&#x6D88;&apos;</span>,</div><div class="line">        <span class="attr">buttonClicked</span>: <span class="function"><span class="keyword">function</span> (<span class="params">index</span>) </span>{</div><div class="line">          <span class="keyword">switch</span> (index) {</div><div class="line">            <span class="keyword">case</span> <span class="number">0</span>:</div><div class="line">              func_getPicFromCamera();</div><div class="line">              <span class="keyword">break</span>;</div><div class="line">            <span class="keyword">case</span> <span class="number">1</span>:</div><div class="line">              func_getPicFromPicture();</div><div class="line">              <span class="keyword">break</span>;</div><div class="line">          }</div><div class="line">          <span class="keyword">return</span> <span class="literal">true</span>;</div><div class="line">        }</div><div class="line">      });</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// &#x4ECE;&#x6444;&#x50CF;&#x5934;&#x83B7;&#x53D6;&#x56FE;&#x7247;</span></div><div class="line">    <span class="keyword">var</span> func_getPicFromCamera = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">      <span class="keyword">var</span> options = {</div><div class="line">        <span class="attr">quality</span>: <span class="number">100</span>,</div><div class="line">        <span class="attr">destinationType</span>: Camera.DestinationType.DATA_URL,</div><div class="line">        <span class="attr">sourceType</span>: Camera.PictureSourceType.CAMERA,</div><div class="line">        <span class="attr">allowEdit</span>: <span class="literal">true</span>,</div><div class="line">        <span class="attr">encodingType</span>: Camera.EncodingType.JPEG,</div><div class="line">        <span class="attr">targetWidth</span>: <span class="number">100</span>,</div><div class="line">        <span class="attr">targetHeight</span>: <span class="number">100</span>,</div><div class="line">        <span class="attr">popoverOptions</span>: CameraPopoverOptions,</div><div class="line">        <span class="attr">saveToPhotoAlbum</span>: <span class="literal">false</span>,</div><div class="line">        <span class="attr">correctOrientation</span>: <span class="literal">true</span></div><div class="line">      };</div><div class="line"></div><div class="line">      $cordovaCamera.getPicture(options).then(<span class="function"><span class="keyword">function</span> (<span class="params">imageData</span>) </span>{</div><div class="line">        <span class="comment">// &#x83B7;&#x53D6;&#x9875;&#x9762;&#x4E2D;&#x7684;img&#x5BF9;&#x8C61;</span></div><div class="line">        <span class="keyword">var</span> image = <span class="built_in">document</span>.getElementById(<span class="string">&apos;touxiang&apos;</span>);</div><div class="line">        image.src = <span class="string">&quot;data:image/jpeg;base64,&quot;</span> + imageData;</div><div class="line">        <span class="comment">// &#x4FDD;&#x5B58;&#x6211;&#x4EEC;&#x83B7;&#x53D6;&#x7684;&#x5934;&#x50CF;&#x6570;&#x636E;&#xFF0C;&#x4E0B;&#x6B21;&#x767B;&#x5F55;&#x7684;&#x65F6;&#x5019;&#x5C31;&#x53EF;&#x4EE5;&#x663E;&#x793A;&#x4E86;&#x5427;</span></div><div class="line">        localStorage[<span class="string">&quot;touxiang&quot;</span>] = imageData;</div><div class="line">      }, <span class="function"><span class="keyword">function</span> (<span class="params">err</span>) </span>{</div><div class="line">        <span class="comment">//$scope.AlertPopup(err);</span></div><div class="line">      });</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// &#x4ECE;&#x56FE;&#x5E93;&#x83B7;&#x53D6;&#x56FE;&#x7247;</span></div><div class="line">    <span class="keyword">var</span> func_getPicFromPicture = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line"></div><div class="line">      <span class="keyword">var</span> options = {</div><div class="line">        <span class="attr">quality</span>: <span class="number">100</span>,</div><div class="line">        <span class="attr">destinationType</span>: Camera.DestinationType.DATA_URL,</div><div class="line">        <span class="attr">sourceType</span>: Camera.PictureSourceType.PHOTOLIBRARY,</div><div class="line">        <span class="attr">allowEdit</span>: <span class="literal">true</span>,</div><div class="line">        <span class="attr">encodingType</span>: Camera.EncodingType.JPEG,</div><div class="line">        <span class="attr">targetWidth</span>: <span class="number">100</span>,</div><div class="line">        <span class="attr">targetHeight</span>: <span class="number">100</span>,</div><div class="line">        <span class="attr">popoverOptions</span>: CameraPopoverOptions,</div><div class="line">        <span class="attr">saveToPhotoAlbum</span>: <span class="literal">false</span>,</div><div class="line">        <span class="attr">correctOrientation</span>: <span class="literal">true</span></div><div class="line">      };</div><div class="line"></div><div class="line">      $cordovaCamera.getPicture(options).then(<span class="function"><span class="keyword">function</span> (<span class="params">imageData</span>) </span>{</div><div class="line">        <span class="comment">// &#x83B7;&#x53D6;&#x9875;&#x9762;&#x4E2D;&#x7684; img &#x6807;&#x7B7E;</span></div><div class="line">        <span class="keyword">var</span> image = <span class="built_in">document</span>.getElementById(<span class="string">&apos;touxiang&apos;</span>);</div><div class="line">        image.src = <span class="string">&quot;data:image/jpeg;base64,&quot;</span> + imageData;</div><div class="line">        localStorage[<span class="string">&quot;touxiang&quot;</span>] = imageData;</div><div class="line">      }, <span class="function"><span class="keyword">function</span> (<span class="params">err</span>) </span>{</div><div class="line">        <span class="comment">//$scope.AlertPopup(err);</span></div><div class="line">      });</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// &#x6253;&#x7535;&#x8BDD;</span></div><div class="line">    $scope.func_callPhone = <span class="function"><span class="keyword">function</span> (<span class="params">number</span>) </span>{</div><div class="line">      $<span class="built_in">window</span>.location.href = <span class="string">&quot;tel:&quot;</span> + number;</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// &#x9000;&#x51FA;&#x65B9;&#x6CD5;</span></div><div class="line">    $scope.func_exitApp = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">      <span class="keyword">var</span> confirmPopup = $ionicPopup.confirm({</div><div class="line">        <span class="attr">title</span>: <span class="string">&apos;&#x63D0;&#x793A;&apos;</span>,</div><div class="line">        <span class="attr">template</span>: <span class="string">&quot;&#x786E;&#x8BA4;&#x9000;&#x51FA;&#xFF1F;&quot;</span></div><div class="line">      });</div><div class="line">      confirmPopup.then(<span class="function"><span class="keyword">function</span> (<span class="params">res</span>) </span>{</div><div class="line">        <span class="keyword">if</span> (res) {</div><div class="line">          <span class="comment">// &#x9000;&#x51FA; app</span></div><div class="line">          ionic.Platform.exitApp();</div><div class="line">        }</div><div class="line">      });</div><div class="line">    }</div><div class="line">  });</div></pre></td></tr></table></figure>
<p>&#x6CE8;&#x610F;&#x70B9;&#xFF1A;</p>
<p>&#x4E00;&#x5B9A;&#x8981;&#x628A; common.css &#x4E2D;&#x7684;&#x5173;&#x4E8E; actionsheet &#x7684;&#x6837;&#x5F0F;&#x7ED9;&#x52A0;&#x8F7D;&#x8FDB;&#x53BB;&#xFF0C;&#x5426;&#x5219;&#x6837;&#x5F0F;&#x6253;&#x5305;&#x4E4B;&#x540E;&#x4F1A;&#x9519;&#x4E71;</p>
<p>&#x600E;&#x4E48;&#x8C03;&#x7528; cordova-camara &#x63D2;&#x4EF6;</p>
<p><a href="http://my.oschina.net/u/1416844/blog/491533" target="_blank" rel="external">http://my.oschina.net/u/1416844/blog/491533</a></p>
<p>&#x5E38;&#x89C1;&#x95EE;&#x9898;</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic36.png" alt="&#x5E38;&#x89C1;&#x95EE;&#x9898;"></p>
<p>&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x4F60;&#x9700;&#x8981;&#x8FD0;&#x884C;:</p>
<p><img src="/2016/12/14/s016-ionic-cordova-AngularJS&#x6DF7;&#x5408;app&#x5F00;&#x53D1;&#x7B14;&#x8BB0;/ionic37.png" alt="&#x8FD0;&#x884C;"></p>
<p>Base64&#x6587;&#x4EF6;&#x4ECB;&#x7ECD;</p>
<p><a href="http://www.aimks.com/css-path-data-image-png-usage-base64.html" target="_blank" rel="external">http://www.aimks.com/css-path-data-image-png-usage-base64.html</a><br><a href="http://www.zhihu.com/question/36306744/answer/71626823" target="_blank" rel="external">http://www.zhihu.com/question/36306744/answer/71626823</a></p>
<h2 id="&#x767D;&#x540D;&#x5355;&#x8BBE;&#x7F6E;"><a href="#&#x767D;&#x540D;&#x5355;&#x8BBE;&#x7F6E;" class="headerlink" title="&#x767D;&#x540D;&#x5355;&#x8BBE;&#x7F6E;"></a>&#x767D;&#x540D;&#x5355;&#x8BBE;&#x7F6E;</h2><h3 id="&#x9875;&#x9762;&#x4EE3;&#x7801;"><a href="#&#x9875;&#x9762;&#x4EE3;&#x7801;" class="headerlink" title="&#x9875;&#x9762;&#x4EE3;&#x7801;"></a>&#x9875;&#x9762;&#x4EE3;&#x7801;</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">class</span>=<span class="string">&quot;telephone&quot;</span> <span class="attr">href</span>=<span class="string">&quot;tel:88889999&quot;</span>&gt;</span>88889999<span class="tag">&lt;/<span class="name">a</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="&#x8BBE;&#x7F6E;&#x767D;&#x540D;&#x5355;"><a href="#&#x8BBE;&#x7F6E;&#x767D;&#x540D;&#x5355;" class="headerlink" title="&#x8BBE;&#x7F6E;&#x767D;&#x540D;&#x5355;"></a>&#x8BBE;&#x7F6E;&#x767D;&#x540D;&#x5355;</h3><p><a href="http://rickluna.com/wp/2012/02/making-a-phone-call-from-within-phonegap-in-android-and-ios/" target="_blank" rel="external">http://rickluna.com/wp/2012/02/making-a-phone-call-from-within-phonegap-in-android-and-ios/</a></p>
<h2 id="app&#x56FE;&#x6807;"><a href="#app&#x56FE;&#x6807;" class="headerlink" title="app&#x56FE;&#x6807;"></a>app&#x56FE;&#x6807;</h2><p>&#x5728;&#x9879;&#x76EE;&#x7684;&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA; resources &#x6587;&#x4EF6;&#x5939;&#x3002;</p>
<p>&#x5728;&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#x90FD;&#x653E;&#x5165; icon.png&#xFF08;&#x5E94;&#x7528;&#x56FE;&#x6807;&#xFF0C;&#x6700;&#x5C0F; 192x192px&#xFF0C;&#x4E0D;&#x5E26;&#x5706;&#x89D2;&#xFF09;&#xFF0C;splash.png&#xFF08;&#x542F;&#x52A8;&#x5C4F;&#x5E55;&#xFF0C;&#x6700;&#x5C0F; 2208x2208px&#xFF0C;&#x4E2D;&#x95F4;&#x533A;&#x57DF; 1200x1200px &#xFF09;(&#x53EF;&#x4EE5;&#x662F; png&#x3001;psd&#x3001;ai)</p>
<p>&#x5728; cmd &#x4E2D;&#x8FDB;&#x5165;&#x9879;&#x76EE;&#x6240;&#x5728;&#x6587;&#x4EF6;&#x5939;&#x6267;&#x884C;&#xFF1A;&#x5FC5;&#x987B;&#x8054;&#x7F51;</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">ionic resources --icon       </div><div class="line">ionic resources --splash</div></pre></td></tr></table></figure>
<p>&#x9879;&#x76EE;&#x4E2D;&#x7684;config&#x6587;&#x4EF6;&#x4E2D;&#x662F;&#x8FD9;&#x6837;</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">platform</span> <span class="attr">name</span>=<span class="string">&quot;android&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">icon</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\icon\drawable-ldpi-icon.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;ldpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">icon</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\icon\drawable-mdpi-icon.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;mdpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">icon</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\icon\drawable-hdpi-icon.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;hdpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">icon</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\icon\drawable-xhdpi-icon.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;xhdpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">icon</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\icon\drawable-xxhdpi-icon.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;xxhdpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">splash</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\splash\drawable-land-ldpi-screen.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;land-ldpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">splash</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\splash\drawable-land-mdpi-screen.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;land-mdpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">splash</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\splash\drawable-port-ldpi-screen.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;port-ldpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">splash</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\splash\drawable-port-mdpi-screen.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;port-mdpi&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">splash</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\splash\drawable-port-hdpi-screen.png&quot;</span> <span class="attr">density</span>=<span class="string">&quot;port-hdpi&quot;</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">platform</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">icon</span> <span class="attr">src</span>=<span class="string">&quot;resources\android\icon\drawable-xhdpi-icon.png&quot;</span>/&gt;</span></div></pre></td></tr></table></figure>
<p>&#x56E0;&#x4E3A;&#x5728;&#x8FD0;&#x884C;&#x7684;&#x65F6;&#x5019;&#x8981;&#x4E0A;&#x4F20;&#x56FE;&#x7247;&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x8054;&#x7F51;&#x4E0D;&#x9519;&#x7684;&#x63D2;&#x4EF6;</p>
<h2 id="&#x53CC;&#x51FB;&#x9000;&#x51FA;&#x5E94;&#x7528;"><a href="#&#x53CC;&#x51FB;&#x9000;&#x51FA;&#x5E94;&#x7528;" class="headerlink" title="&#x53CC;&#x51FB;&#x9000;&#x51FA;&#x5E94;&#x7528;"></a>&#x53CC;&#x51FB;&#x9000;&#x51FA;&#x5E94;&#x7528;</h2><p>&#x5B9E;&#x73B0;&#x601D;&#x8DEF;</p>
<blockquote>
<p>$cordovaToast<br>$ionicPlatform.registerBackButtonAction<br>$location.path</p>
</blockquote>
<p>&#x5224;&#x65AD;&#x65F6;&#x5019;&#x662F;&#x7B2C;&#x4E00;&#x6B21;&#x8FDB;&#x5165;&#x5E94;&#x7528;</p>
<h2 id="&#x5176;&#x4ED6;&#x5E73;&#x53F0;&#x4ECB;&#x7ECD;"><a href="#&#x5176;&#x4ED6;&#x5E73;&#x53F0;&#x4ECB;&#x7ECD;" class="headerlink" title="&#x5176;&#x4ED6;&#x5E73;&#x53F0;&#x4ECB;&#x7ECD;"></a>&#x5176;&#x4ED6;&#x5E73;&#x53F0;&#x4ECB;&#x7ECD;</h2><p>P++&#x652F;&#x4ED8;&#x5E73;&#x53F0;<br>&#x6781;&#x5149;&#x63A8;&#x9001;&#x5E73;&#x53F0;<br>&#x5FAE;&#x4FE1;&#x5F00;&#x53D1;&#x5E73;&#x53F0;</p>
<h2 id="&#x9879;&#x76EE;&#x4F18;&#x5316;"><a href="#&#x9879;&#x76EE;&#x4F18;&#x5316;" class="headerlink" title="&#x9879;&#x76EE;&#x4F18;&#x5316;"></a>&#x9879;&#x76EE;&#x4F18;&#x5316;</h2><p>&#x4F7F;&#x7528;gulp&#x538B;&#x7F29;&#x6E90;&#x4EE3;&#x7801;</p>
<h2 id="&#x63D2;&#x4EF6;&#x6269;&#x5C55;"><a href="#&#x63D2;&#x4EF6;&#x6269;&#x5C55;" class="headerlink" title="&#x63D2;&#x4EF6;&#x6269;&#x5C55;"></a>&#x63D2;&#x4EF6;&#x6269;&#x5C55;</h2><p><a href="http://git.oschina.net/Cheergoal/BarcodeScanner" target="_blank" rel="external">http://git.oschina.net/Cheergoal/BarcodeScanner</a><br><a href="http://cordova.apache.org/docs/en/latest/guide/hybrid/plugins/index.html" target="_blank" rel="external">http://cordova.apache.org/docs/en/latest/guide/hybrid/plugins/index.html</a><br><a href="http://www.iteye.com/blogs/subjects/cordova" target="_blank" rel="external">http://www.iteye.com/blogs/subjects/cordova</a><br><a href="http://www.oschina.net/question/2296277_232018" target="_blank" rel="external">http://www.oschina.net/question/2296277_232018</a><br>angular&#xFF0C;ui-router&#xFF0C;indexdb&#xFF0C;swiper, &#x5A92;&#x4F53;&#x67E5;&#x8BE2;&#xFF0C;rem&#xFF0C;cordova&#xFF0C;ng-cordova&#xFF0C;Promise/A+<br>css3, scss, gulp</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>感谢您的支持！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>打 赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="http://ofy7k3v4s.bkt.clouddn.com/wcpayCode.jpg" alt="Hongqin Ma WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="http://ofy7k3v4s.bkt.clouddn.com/apayCode.jpg" alt="Hongqin Ma Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/ionic/" rel="tag">#ionic</a>
          
            <a href="/tags/cordova/" rel="tag">#cordova</a>
          
            <a href="/tags/AngularJS/" rel="tag">#AngularJS</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/12/09/s016-ionic-js笔记/" rel="next" title="ionic js笔记">
                <i class="fa fa-chevron-left"></i> ionic js笔记
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/"
     data-title="ionic+cordova+AngularJS混合app开发笔记"
     data-content=""
     data-url="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/"
           data-title="ionic+cordova+AngularJS混合app开发笔记" data-url="https://hongqinma.github.io/2016/12/14/s016-ionic-cordova-AngularJS混合app开发笔记/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/photo.jpg"
               alt="Hongqin Ma" />
          <p class="site-author-name" itemprop="name">Hongqin Ma</p>
          <p class="site-description motion-element" itemprop="description">Spell at all costs， to rush you in the future. </p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">68</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">57</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/HongqinMa" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/HongqinMa" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.facebook.com/profile.php?id=100006581058735" target="_blank" title="Facebook">
                  
                    <i class="fa fa-fw fa-facebook"></i>
                  
                  Facebook
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/HirakuMa" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-share-alt"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/rubylouvre/" title="司徒正美" target="_blank">司徒正美</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/sanshi/" title="三生石上" target="_blank">三生石上</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/TomXu/" title="汤姆大叔" target="_blank">汤姆大叔</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://gold.xitu.io/" title="掘金" target="_blank">掘金</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://segmentfault.com/" title="segmentfault" target="_blank">segmentfault</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.jianshu.com/users/1cbb94e5ed4d/latest_articles" title="简书" target="_blank">简书</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://home.cnblogs.com/" title="博客园" target="_blank">博客园</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.awesomes.cn/" title="Awesomes" target="_blank">Awesomes</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#ionic-项目"><span class="nav-number">1.</span> <span class="nav-text">ionic 项目</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#项目结构说明"><span class="nav-number">1.1.</span> <span class="nav-text">项目结构说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#打包app"><span class="nav-number">1.2.</span> <span class="nav-text">打包app</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#项目结构搭建"><span class="nav-number">2.</span> <span class="nav-text">项目结构搭建</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#要从新整理结构"><span class="nav-number">2.1.</span> <span class="nav-text">要从新整理结构</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#抽取步骤"><span class="nav-number">2.2.</span> <span class="nav-text">抽取步骤</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#功能模块划分"><span class="nav-number">2.2.1.</span> <span class="nav-text">功能模块划分</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#外面四个js实现步骤"><span class="nav-number">2.2.2.</span> <span class="nav-text">外面四个js实现步骤</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#app-js"><span class="nav-number">2.2.3.</span> <span class="nav-text">app.js</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#route-js"><span class="nav-number">2.2.4.</span> <span class="nav-text">route.js</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Global-Js"><span class="nav-number">2.2.5.</span> <span class="nav-text">Global.Js</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Config-js"><span class="nav-number">2.2.6.</span> <span class="nav-text">Config.js</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#功能模块-js-的整理步骤"><span class="nav-number">2.3.</span> <span class="nav-text">功能模块 js 的整理步骤</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#扩展链接"><span class="nav-number">2.4.</span> <span class="nav-text">扩展链接</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#路由"><span class="nav-number">3.</span> <span class="nav-text">路由</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Ui-router的介绍"><span class="nav-number">3.1.</span> <span class="nav-text">Ui-router的介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#抽象路由的实现"><span class="nav-number">3.2.</span> <span class="nav-text">抽象路由的实现</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ionic中路由实现"><span class="nav-number">3.3.</span> <span class="nav-text">ionic中路由实现</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#tab-router-js"><span class="nav-number">3.4.</span> <span class="nav-text">tab_router.js</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#home-route-js"><span class="nav-number">3.5.</span> <span class="nav-text">home_route.js</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#route-js-1"><span class="nav-number">3.6.</span> <span class="nav-text">route.js</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#index-html"><span class="nav-number">3.7.</span> <span class="nav-text">index.html</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#引导页的实现"><span class="nav-number">4.</span> <span class="nav-text">引导页的实现</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#创建引导页步骤"><span class="nav-number">4.1.</span> <span class="nav-text">创建引导页步骤</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Swiper3简介"><span class="nav-number">4.2.</span> <span class="nav-text">Swiper3简介</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用swiper步骤"><span class="nav-number">4.3.</span> <span class="nav-text">使用swiper步骤</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#首页的实现"><span class="nav-number">5.</span> <span class="nav-text">首页的实现</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#项目布局改造"><span class="nav-number">5.1.</span> <span class="nav-text">项目布局改造</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Tab模板改造"><span class="nav-number">5.2.</span> <span class="nav-text">Tab模板改造</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#动态生成swiper"><span class="nav-number">5.3.</span> <span class="nav-text">动态生成swiper</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ion-view-的生命周期"><span class="nav-number">6.</span> <span class="nav-text">ion-view 的生命周期</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ionic中清理缓存的四种方法"><span class="nav-number">7.</span> <span class="nav-text">ionic中清理缓存的四种方法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#延迟加载的实现"><span class="nav-number">8.</span> <span class="nav-text">延迟加载的实现</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#延迟加载插件使用步骤"><span class="nav-number">8.1.</span> <span class="nav-text">延迟加载插件使用步骤</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ionic中的页面跳转和参数传递"><span class="nav-number">9.</span> <span class="nav-text">ionic中的页面跳转和参数传递</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#ionic中的路由跳转方式"><span class="nav-number">9.1.</span> <span class="nav-text">ionic中的路由跳转方式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ionic中的参数传递"><span class="nav-number">9.2.</span> <span class="nav-text">ionic中的参数传递</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数据请求"><span class="nav-number">10.</span> <span class="nav-text">数据请求</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Angular中的service-父级概念"><span class="nav-number">10.1.</span> <span class="nav-text">Angular中的service(父级概念)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#http服务使用"><span class="nav-number">10.2.</span> <span class="nav-text">$http服务使用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#q服务"><span class="nav-number">10.3.</span> <span class="nav-text">$q服务</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Promise-A-规范"><span class="nav-number">11.</span> <span class="nav-text">Promise/A+规范</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Promise-A-规范简介"><span class="nav-number">11.1.</span> <span class="nav-text">Promise/A+规范简介</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Promise的实现"><span class="nav-number">11.2.</span> <span class="nav-text">Promise的实现</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#规范出现的原因"><span class="nav-number">11.3.</span> <span class="nav-text">规范出现的原因</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#规范的内容是什么（重要）"><span class="nav-number">11.4.</span> <span class="nav-text">规范的内容是什么（重要）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#原理图"><span class="nav-number">11.5.</span> <span class="nav-text">原理图</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#怎么对promise对象的状态进行改变那"><span class="nav-number">11.6.</span> <span class="nav-text">怎么对promise对象的状态进行改变那</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Promise-A-规范表现形式"><span class="nav-number">11.7.</span> <span class="nav-text">Promise/A+规范表现形式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#完整使用说明"><span class="nav-number">11.8.</span> <span class="nav-text">完整使用说明</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#下拉刷新"><span class="nav-number">12.</span> <span class="nav-text">下拉刷新</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#ion-refresher-介绍"><span class="nav-number">12.1.</span> <span class="nav-text">ion-refresher 介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用介绍"><span class="nav-number">12.2.</span> <span class="nav-text">使用介绍</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#上拉加载更多"><span class="nav-number">13.</span> <span class="nav-text">上拉加载更多</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#ion-infinite-scroll-介绍"><span class="nav-number">13.1.</span> <span class="nav-text">ion-infinite-scroll 介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用介绍-1"><span class="nav-number">13.2.</span> <span class="nav-text">使用介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#emit-on"><span class="nav-number">13.3.</span> <span class="nav-text">$emit.$on</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#生命周期的问题"><span class="nav-number">13.4.</span> <span class="nav-text">生命周期的问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#没有数据提示问题"><span class="nav-number">13.5.</span> <span class="nav-text">没有数据提示问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#循环加载的问题"><span class="nav-number">13.6.</span> <span class="nav-text">循环加载的问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#遮罩层"><span class="nav-number">13.7.</span> <span class="nav-text">遮罩层</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#IndexedDb"><span class="nav-number">14.</span> <span class="nav-text">IndexedDb</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#简介"><span class="nav-number">14.1.</span> <span class="nav-text">简介</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#和-webSQL-的比较"><span class="nav-number">14.2.</span> <span class="nav-text">和 webSQL 的比较</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#操作-indexedDB"><span class="nav-number">15.</span> <span class="nav-text">操作 indexedDB</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ng-cordova"><span class="nav-number">16.</span> <span class="nav-text">ng-cordova</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#官网"><span class="nav-number">16.1.</span> <span class="nav-text">官网</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用步骤"><span class="nav-number">16.2.</span> <span class="nav-text">使用步骤</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#调用手机摄像头功能保存头像"><span class="nav-number">17.</span> <span class="nav-text">调用手机摄像头功能保存头像</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#白名单设置"><span class="nav-number">18.</span> <span class="nav-text">白名单设置</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#页面代码"><span class="nav-number">18.1.</span> <span class="nav-text">页面代码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#设置白名单"><span class="nav-number">18.2.</span> <span class="nav-text">设置白名单</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#app图标"><span class="nav-number">19.</span> <span class="nav-text">app图标</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#双击退出应用"><span class="nav-number">20.</span> <span class="nav-text">双击退出应用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#其他平台介绍"><span class="nav-number">21.</span> <span class="nav-text">其他平台介绍</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#项目优化"><span class="nav-number">22.</span> <span class="nav-text">项目优化</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#插件扩展"><span class="nav-number">23.</span> <span class="nav-text">插件扩展</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Hongqin Ma</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_pv">
    &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Page Views: <span id="busuanzi_value_site_pv"></span> 
</span>

        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span>
  

  
    <span class="site-pv"><i class="fa fa-eye"></i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span></span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"Hiraku"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  <!-- custom analytics part create by xiamo -->
<script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
<script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
<script>
function showTime(Counter) {
  var query = new AV.Query(Counter);
  $(".leancloud_visitors").each(function() {
    var url = $(this).attr("id").trim();
    query.equalTo("url", url);
    query.find({
      success: function(results) {
        if (results.length == 0) {
          var content = '0 ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
          return;
        }
        for (var i = 0; i < results.length; i++) {
          var object = results[i];
          var content = object.get('time') + ' ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
        }
      },
      error: function(object, error) {
        console.log("Error: " + error.code + " " + error.message);
      }
    });

  });
}

function addCount(Counter) {
  var Counter = AV.Object.extend("Counter");
  url = $(".leancloud_visitors").attr('id').trim();
  title = $(".leancloud_visitors").attr('data-flag-title').trim();
  var query = new AV.Query(Counter);
  query.equalTo("url", url);
  query.find({
    success: function(results) {
      if (results.length > 0) {
        var counter = results[0];
        counter.fetchWhenSave(true);
        counter.increment("time");
        counter.save(null, {
          success: function(counter) {
            var content =  counter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(counter, error) {
            console.log('Failed to save Visitor num, with error message: ' + error.message);
          }
        });
      } else {
        var newcounter = new Counter();
        newcounter.set("title", title);
        newcounter.set("url", url);
        newcounter.set("time", 1);
        newcounter.save(null, {
          success: function(newcounter) {
              console.log("newcounter.get('time')="+newcounter.get('time'));
            var content = newcounter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(newcounter, error) {
            console.log('Failed to create');
          }
        });
      }
    },
    error: function(error) {
      console.log('Error:' + error.code + " " + error.message);
    }
  });
}
$(function() {
  var Counter = AV.Object.extend("Counter");
  if ($('.leancloud_visitors').length == 1) {
    addCount(Counter);
  } else if ($('.post-title-link').length > 1) {
    showTime(Counter);
  }
}); 
</script>

  
</body>
</html>
